Skip to content

Change inference.md as needed for 4718 - #4724

Open
eernstg wants to merge 2 commits into
mainfrom
spec_4718_jul26
Open

Change inference.md as needed for 4718#4724
eernstg wants to merge 2 commits into
mainfrom
spec_4718_jul26

Conversation

@eernstg

@eernstg eernstg commented Jul 10, 2026

Copy link
Copy Markdown
Member

This PR changes the specification of type inference such that the inferred return type of a generator function literal does not include a spurious Null, which is otherwise added in the case where the end of the body of the function literal can be reached. For example, () sync* {} has inferred return type Iterable<Null>, but with this change it will be Iterable<Never>, as it should be.

**definite completion** analysis specified elsewhere.
- Let `T` be `Null` if any control path reaches the end of the block
without exiting the block, as computed by the **definite completion**
analysis specified elsewhere.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(You can probably guess I'd prefer that case to have type void 😁 . Not returning something is not the same as returning null. It's the same as not returning anything useful. Alas, not where we are today.)

block without reaching the end of the block, as computed by the
**definite completion** analysis specified elsewhere.
- Let `T` be `Null` if any control path reaches the end of the block
without exiting the block, as computed by the **definite completion**

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is "without exiting the block" redundant? Or just confusing?
If control reaches the end, then it definitely didn't exit before that.
On the other hand, it will exit as the very next thing, so does it really "reach then end of the block without exiting" when it "reaches the block and exits"?

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.

2 participants