cli: disambiguate block statement boundaries

This commit is contained in:
dev committed 2026-10-07 18:21:07 +03:00
1 parent 462ddd2c5c
commit 911982dd1c
33 files changed
+465 -7

No files matched your search

+7
View File
@@ -52,6 +52,13 @@ int_type = "u8" | "u16" | "u32" | "u64" | "u128" | "usize"
(* A built-in operation is a call whose callee is a dotted path:
`own.new(v, mem)`, `region.new(arena, v)`, `cap.narrow.budget(c, n)`. *)
(* Statement/tail disambiguation (spec 15 §4): leading bare if_expr,
match_expr or block is consumed whole before choosing the production.
Next `}` makes it the tail, `;` explicitly discards its result, otherwise
it is a block_stmt whose result must be void or divergence (E7006).
No outer postfix/cast/binary continuation is consumed here; parenthesize
the construct for continuation. Nested expr contexts are unrestricted.
Other block_stmt forms end at their final `}`. Whitespace is irrelevant. *)
block = "{" { statement } [ expr ] "}" ; (* optional tail expression: the block's value *)
statement = "let" binding [ ":" type ] "=" expr ";"
| "var" ident ":" type "=" ( expr | "zero" ) ";"