Skip to content

Support return statement type inference with merge vertex pattern#29

Merged
dak2 merged 1 commit intomainfrom
return-statement-type-inference
Feb 22, 2026
Merged

Support return statement type inference with merge vertex pattern#29
dak2 merged 1 commit intomainfrom
return-statement-type-inference

Conversation

@dak2
Copy link
Owner

@dak2 dak2 commented Feb 22, 2026

Previously, method return types were inferred only from the last expression in the method body. This missed explicit return statements, causing false positives when a method used early returns with different types (e.g., return "" if error; 42).

Introduce a merge vertex per method scope that collects types from both explicit return values and the implicit last-expression return, producing a union type for accurate method signature inference.

Previously, method return types were inferred only from the last
expression in the method body. This missed explicit `return` statements,
causing false positives when a method used early returns with different
types (e.g., `return "" if error; 42`).

Introduce a merge vertex per method scope that collects types from both
explicit `return` values and the implicit last-expression return,
producing a union type for accurate method signature inference.
@dak2 dak2 force-pushed the return-statement-type-inference branch from f38e623 to 0ec147f Compare February 22, 2026 01:58
@dak2 dak2 merged commit b42e628 into main Feb 22, 2026
2 checks passed
@dak2 dak2 deleted the return-statement-type-inference branch February 22, 2026 02:02
@dak2 dak2 mentioned this pull request Feb 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant