Repository navigation
D58: a bare let-else else ending the line is a parse error with the else: fix-it (§9.7, §29.13, §30.4) - #1571
Merged
Merged
Conversation
… `else:` fix-it (§9.7, §29.13, §30.4)
D58 (blessed 2026-09-22): the `else` of `let PATTERN = EXPR else` takes a
§29.13 body (`else: stmt`, `else:` + indented block, `else { ... }`) or a
single diverging expression on the same line (`else return -1`). `else` +
newline + an indented block with no introducer is a parse error.
The compiler still accepted it: Parser.parse_let_else_body advanced over an
optional `:` and handed a NEWLINE straight to parse_block_or_expr, which
takes a newline as the indented-block form whether or not a colon opened it
(#1397 pinned the shape in behav_let_else_block_body's `bare_indented`).
Now a NEWLINE directly after `else` reports, at the `else`:
error: expected ':' after 'else': a let-else branch on the next line is a body (§9.7)
= help: write `else:` to introduce the indented block; only a single
diverging expression may follow a bare `else`, on the same line
and parses on as if the colon were written, so the indented branch raises
nothing further (one error per site; a dedented next line still adds the
#1382 indented-block error).
Matrix (stage1 before -> after), let/var/unit-variant heads:
else\n<block> ok -> error + help (let, var, `let A = s`, trailing comment)
else\n<dedented> indented-block error -> both errors
else return -1 ok -> ok
else: return -1 ok -> ok
else:\n<block> ok -> ok
else { ... } / multi ok -> ok
else print("x") must-diverge error -> unchanged
Tree rewrite: tools/migrate_let_else_colon.w (Lexer-selected: an `else`
token followed by a newline token whose logical line starts with let/var)
over src lib tools test examples build build.w found one site, the
behav_let_else_block_body cell that pinned the removed form; it now writes
`else:` (renamed indented_option). No release UAT fixture, example or blog
program used the form. `stage1 check src/main.w`: ok.
New fixture: test/compile_errors/err_let_else_bare_else_next_line.w.
else ending the line is a parse error with the else: fix-it (§9.7, §29.13, §30.4)
Contributor
Author
|
Stack #1582 battery (seed-driven, new seed, cold c_import cache, with :drop-audit/:move-audit) on main 02301f8 + #1571 → … → #1581 (head dca1a8f; every PR head is a tested commit): build ok, :fixpoint ok, :drop-audit ok, :move-audit ok, :test ok (no reds), :test-green ok, :last-green ok. Merges cleanly into main. Merge the stack: |
ehartford
marked this pull request as ready for review
September 23, 2026 22:04
This was referenced Sep 23, 2026
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.
D58 (blessed 2026-09-22): the
elseoflet PATTERN = EXPR elsetakes a§29.13 body (
else: stmt,else:+ indented block,else { ... }) or asingle diverging expression on the same line (
else return -1).else+newline + an indented block with no introducer is a parse error.
The compiler still accepted it: Parser.parse_let_else_body advanced over an
optional
:and handed a NEWLINE straight to parse_block_or_expr, whichtakes a newline as the indented-block form whether or not a colon opened it
(#1397 pinned the shape in behav_let_else_block_body's
bare_indented).Now a NEWLINE directly after
elsereports, at theelse:error: expected ':' after 'else': a let-else branch on the next line is a body (§9.7)
= help: write
else:to introduce the indented block; only a singlediverging expression may follow a bare
else, on the same lineand parses on as if the colon were written, so the indented branch raises
nothing further (one error per site; a dedented next line still adds the
#1382 indented-block error).
Matrix (stage1 before -> after), let/var/unit-variant heads:
else\n ok -> error + help (let, var,
let A = s, trailing comment)else\n indented-block error -> both errors
else return -1 ok -> ok
else: return -1 ok -> ok
else:\n ok -> ok
else { ... } / multi ok -> ok
else print("x") must-diverge error -> unchanged
Tree rewrite: tools/migrate_let_else_colon.w (Lexer-selected: an
elsetoken followed by a newline token whose logical line starts with let/var)
over src lib tools test examples build build.w found one site, the
behav_let_else_block_body cell that pinned the removed form; it now writes
else:(renamed indented_option). No release UAT fixture, example or blogprogram used the form.
stage1 check src/main.w: ok.New fixture: test/compile_errors/err_let_else_bare_else_next_line.w.
Stack #1582, layer 1/11. Draft until the batch battery is green (D56).