You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
let-else: a multi-statement indented else block does not parse as a block ("requires a diverging else branch" on its first statement) #1382
The else branch of let PAT = subject else: may be any diverging body (§9.7: "The else branch must diverge (return, break, continue, panic)"). An indented multi-statement block ending in return is rejected: only its first statement is taken as the else body.
fn int_or_err(k: i32) -> Result[i32, str]:
if k == 0: return Err("none".clone())
k
fn h(k: i32) -> i32:
let Ok(v) = int_or_err(k) else:
print("miss")
return -1
v
fn main:
print(f"{h(0)} {h(1)}")
error: let ... else requires a diverging else branch
--> m4.w:6:9
6 | print("miss")
Expected: miss then -1 1.
Likely site: Parser.parse_let_pattern_rest (src/Parser.w ~7105) — if TK_COLON: advance(); skip_newlines(); parse_block_or_expr(): skipping the newline before the indented block makes parse_block_or_expr see the first statement as an expression. The other NK_LET_ELSE producers (7160/7171/7212/7224) should be checked for the same shape.
Found while building the #1365 let-else drop matrix.
Activity
let-else: a let pattern is the match-arm pattern grammar; the else br…
let-else: the failing path drops the whole subject before it diverges…
let-else: the failing path drops the whole subject before it diverges…
let-else: a let pattern is the match-arm pattern grammar; the else br…
let-else: a let pattern is the match-arm pattern grammar; the else br…
let-else: a let pattern is the match-arm pattern grammar; the else br…
let-else: a let pattern is the match-arm pattern grammar; the else br…
D58: a bare let-else `else` ending the line is a parse error with the…
Parser: a body opened at end of line must sit deeper than its constru…
D58: a bare let-else `else` ending the line is a parse error with the…
Parser: a body opened at end of line must sit deeper than its constru…