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
Unannotated fn with early 'return <value>' finalizes as Unit return; caller branches on undef — silent runtime trap #653
The trigger is the presence of an early return <value> statement under return-type inference. Loops are irrelevant (first row has none).
Reproduces identically on installed with v0.15.1-gd527f2992 and on the current D7 dirty-tree compiler — a long-standing bug, not introduced by the receiver migration.
Notes
Sema.infer_unannotated_function_return_type (src/SemaCheck.w:4810) reads body_return_type_info(body); by inspection saw_value_return/value_type should yield bool here, yet the finalized sig is Unit — the exact wrong line is not yet pinned; needs an LLDB pass on the repro before fixing.
Survives checking because if/while condition types are never validated (see companion issue) and no Sema/MIR/LLVM return-consistency audit exists yet (planned with analyze addition).
This is the same defect that produced the line_selected -> void -> switch undef failure in the D7 migration repair tool (docs/handoff.md §5); the tool's fix was the -> bool annotation workaround.
Fixed in e7ffc47. Root cause: check_return computed the return value's type but check_expr does not self-record bool literals or binary-op results into typed_expr_types, so return-type inference read the value back as 0 and misclassified the value-return as bare — finalizing Unit. Fix records the type at the single choke point in check_return. Verified: repro now prints 'yes'; behavior fixtures behav_infer_return_early_{bool_lit,comparison,arith,logical,bool_explicit_tail} + controls; the mixed bare/value case now correctly errors (err_infer_return_mixed_bare_value). Full gate green incl. fixpoint and a signature-fact flip sweep showing 0 changed inferred returns across compiler sources.
Activity
D7 checkpoint: eliminate-self receiver migration + integrated analysi…
MirLower: type the transparent-box deref place; handoff: pin the last
Inventory clusters A/B/C/E: std module repairs, machinery contract co…
Sema: fix return-type inference for early value returns (#653, #659, #…
ehartford commentedon Jul 14, 2026
Fixed in e7ffc47. Root cause: check_return computed the return value's type but check_expr does not self-record bool literals or binary-op results into typed_expr_types, so return-type inference read the value back as 0 and misclassified the value-return as bare — finalizing Unit. Fix records the type at the single choke point in check_return. Verified: repro now prints 'yes'; behavior fixtures behav_infer_return_early_{bool_lit,comparison,arith,logical,bool_explicit_tail} + controls; the mixed bare/value case now correctly errors (err_infer_return_mixed_bare_value). Full gate green incl. fixpoint and a signature-fact flip sweep showing 0 changed inferred returns across compiler sources.