Repository navigation
Conversation
…at the let's line (bendlang#1868) x = v is refused inside a do block with "a pattern (a binder or a constructor)" and the caret on the previous statement, because the leftover = v was re-parsed as the next statement. The typed form (x : T = v, the grammar's DoLet) works; now the refusal says so, where the statement is, and the spec test pins it.
Collaborator
|
Superseded by #1889, which keeps this commit as its first and generalizes the guard: the check now runs where the do block ends and catches any stray |
nicolas-abril
added a commit
that referenced
this pull request
Oct 27, 2026
An untyped do-block let (`x = v`, `(a, b) = v`, `m.k = v`, `return e = v`) leaked its `= v` past the block and surfaced as "a pattern" on the statement before it (#1868). The block's end now refuses any `=` that is not `==` or `=>`, with the caret on the `=`. Supersedes #1870. Co-authored-by: Adeer Khan <[email protected]> Co-authored-by: Claude Opus 5.5 <[email protected]>
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.
Closes #1868
What
x = pure_of()inside adoblock is refused withexpected : a pattern (a binder or a constructor)and the caret on the previous statement (the leftover= vwas being re-parsed as the next statement). The typed form the grammar'sDoLettakes —x : T = v— works; the refusal now says exactly that, located on the let itself:The guard is four conditions in
parse_term_do_stmt, right where a statement term has been parsed: aVarhead, no:to follow (that is the typed path), no==(keep the equality statement as it was), and an=waiting — thenparse_failwith the message above. Nothing else in the statement parse moved.Why
The message named neither the rule nor the line: the caret sat on
IO.print("a")and the observation showed anIO.bind, so the first suspect was the desugaring, not the let. Full characterization (four spellings) in #1868 with the correction comment: typed lets were always fine.Checks
tests/spec/comp_do_let.bend— new spec pin: the refusal above, the location,exit 1. Run withbun bend2/main.ts tests/spec/comp_do_let.bend: output matches the pin.tests/spec/comp_let_split.bend— still refuses identically (its pin unchanged).x : Nat = pure_of()thenIO.print("ok")) still runs and printsok.bun gates/repo.ts:bend2/bend.tsunder its 48k cap; the one red file (bendtt.lean64885 > 64000) is pre-existing onmainand untouched here.gates/test.tsshards need the mini cluster — not run locally; the change is a parse-time refusal on a form that never parsed.