fix(parser): parse braced defer { … } body as a statement block (issue 0065)
A braced `defer` body routed through `parseExpr` + a mandatory trailing
`;`, so it parsed the `{ … }` as a block-EXPRESSION whose statement loop
doesn't handle a destructure decl or a `catch`-statement — `defer { v, e
:= f(); … }` and `defer { x() catch e … }` failed with "expected ';'",
and even `defer { stmt; }` needed a spurious trailing semicolon.
Now the `kw_defer` arm parses a braced body with `parseBlock` (the same
path `onfail` uses), so every statement form works; the bare-expression
form (`defer expr;`) is unchanged. `in_defer_body` is still set before
parsing, so the cleanup-body control-flow bans (return/break/continue/
try/raise) and the E1.7 failable-absorption check still fire.
Resolves the `defer` manifestation of issue 0065 (the general
value-block-in-binding-position destructure remains open). Regression:
examples/1050-errors-defer-block-body.sx.
Gates: zig build, zig build test, run_examples.sh -> 341 passed, 0 failed.
This commit is contained in:
1
examples/expected/1050-errors-defer-block-body.exit
Normal file
1
examples/expected/1050-errors-defer-block-body.exit
Normal file
@@ -0,0 +1 @@
|
||||
0
|
||||
1
examples/expected/1050-errors-defer-block-body.stderr
Normal file
1
examples/expected/1050-errors-defer-block-body.stderr
Normal file
@@ -0,0 +1 @@
|
||||
|
||||
3
examples/expected/1050-errors-defer-block-body.stdout
Normal file
3
examples/expected/1050-errors-defer-block-body.stdout
Normal file
@@ -0,0 +1,3 @@
|
||||
body
|
||||
defer: v=21
|
||||
defer: caught
|
||||
Reference in New Issue
Block a user