Fix type-checker builtin sigs that shadowed std.msh defs#265
Merged
Conversation
Several pure std.msh defs had hand-written Go type sigs in TypeBuiltins.go. Because RegisterStdlibSigs skips names already registered, those Go sigs won over the real std.msh annotations — and could silently drift out of sync. `uw` was the concrete bug: registered as `([t] -- )` while the runtime def is `([str] --)`. That let a program producing `[[str]]` (e.g. a nested `map.`) pass the type checker and then crash at runtime in `unlines`/`join`. Removing the Go entry lets the accurate `[str]` annotation drive the check. Changes: - Remove redundant/incorrect Go sigs for `uw`, `unlines`, `2unpack`, `chomp`; they are exact std.msh defs and are now sourced from the annotation. - `any`/`all`: drop the empty-quote arm `([bool] ( -- ) -- bool)`, leaving the single signature `([T] (T -- bool) -- bool)`. Use `(id)` for a bool list. (Breaking; noted in CHANGELOG.) - Add regression test tests/typecheck_fail/uw_nested_list.msh. - Update the `unlines` builtin-only unit test and the any/all runtime test. Temporarily comment out the basic-sort case in tests/success/sort_test.msh (`[int | str] sort uw`); it depends on the separate `sort -> [str]` fix and will be restored when that lands. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Several pure std.msh defs had hand-written Go type sigs in TypeBuiltins.go. Because RegisterStdlibSigs skips names already registered, those Go sigs won over the real std.msh annotations — and could silently drift out of sync.
uwwas the concrete bug: registered as([t] -- )while the runtime def is([str] --). That let a program producing[[str]](e.g. a nestedmap.) pass the type checker and then crash at runtime inunlines/join. Removing the Go entry lets the accurate[str]annotation drive the check.Changes:
uw,unlines,2unpack,chomp; they are exact std.msh defs and are now sourced from the annotation.any/all: drop the empty-quote arm([bool] ( -- ) -- bool), leaving the single signature([T] (T -- bool) -- bool). Use(id)for a bool list. (Breaking; noted in CHANGELOG.)unlinesbuiltin-only unit test and the any/all runtime test.Temporarily comment out the basic-sort case in tests/success/sort_test.msh (
[int | str] sort uw); it depends on the separatesort -> [str]fix and will be restored when that lands.