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
fix: three compiler fixes for explicit-return functions and Never type
1. unify.ml: add Never (bottom type) as universal unifier
TCon "Never" unifies with any type, allowing functions whose all
paths return via `return expr;` to pass the type checker.
2. typecheck.ml: block divergence propagation
Add always_diverges / block_always_diverges helpers; synth_block
returns ty_never (not ty_unit) when all block paths diverge.
This makes `fn f() -> T { return x; }` typecheck correctly.
3. parser.mly: block_terminator rule for self-delimiting exprs
Split the block rule to accept a `block_terminator` as a final
expression: `if`/`match`/nested-`block` end with `}` and are
LR(1)-distinguishable from statements without consuming a `;`.
Simple literals/idents as block-final still need `return`.
Parser conflicts: 1248 → 1245.
Together these allow real-world AffineScript source to compile:
airborne-submarine-squadron/src/main.as now produces a valid 8KB
WASM 1.0 binary.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
0 commit comments