Skip to content

Fix type-checker builtin sigs that shadowed std.msh defs#265

Merged
mitchpaulus merged 1 commit into
mainfrom
fix-uw-sort-typecheck-sigs
Jul 1, 2026
Merged

Fix type-checker builtin sigs that shadowed std.msh defs#265
mitchpaulus merged 1 commit into
mainfrom
fix-uw-sort-typecheck-sigs

Conversation

@mitchpaulus

Copy link
Copy Markdown
Owner

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.

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>
@mitchpaulus mitchpaulus merged commit a0ed5a6 into main Jul 1, 2026
1 check passed
@mitchpaulus mitchpaulus deleted the fix-uw-sort-typecheck-sigs branch July 1, 2026 21:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant