Check return expressions against the function's declared return type #59

Closed
opened 2026-09-10 22:14:01 +00:00 by jacksonopp · 1 comment
Owner

Type-check Expr::Return's optional value against the enclosing function's declared return type (or Unit when the value is absent), extending #3's return-type checking to early returns, not just a function body's trailing expression.

Type-check Expr::Return's optional value against the enclosing function's declared return type (or Unit when the value is absent), extending #3's return-type checking to early returns, not just a function body's trailing expression.
jacksonopp added this to the twill project 2026-09-10 22:19:56 +00:00
Author
Owner

Resolved in #78: a new check_return checks Expr::Return's optional value against the enclosing function's declared return type (Scope::current_fn_return, set/restored around check_fn's body check), with bare return checked against Unit. Reuses ReturnTypeMismatch/NoTypeProduced, mirrors the -> type carve-out, and defers return-outside-a-function same as break-outside-a-loop.

Resolved in #78: a new `check_return` checks `Expr::Return`'s optional value against the enclosing function's declared return type (`Scope::current_fn_return`, set/restored around `check_fn`'s body check), with bare `return` checked against `Unit`. Reuses `ReturnTypeMismatch`/`NoTypeProduced`, mirrors the `-> type` carve-out, and defers `return`-outside-a-function same as `break`-outside-a-loop.
jacksonopp removed this from the twill project 2026-10-04 02:28:22 +00:00
Sign in to join this conversation.
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
jacksonopp/twill#59
No description provided.