Skip to content

Make function literal return type inference infer void from context #1092

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 15, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions resources/type-system/inference.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ Status: Draft

## CHANGELOG

2020.07.14:
- Infer return type `void` from context with function literals.

2020.06.04:
- Make conflict resolution for override inference explicit.

Expand Down Expand Up @@ -318,9 +321,11 @@ The **actual returned type** of the function literal is the value of `T` after
all `return` and `yield` statements in the block body have been considered.

Let `T` be the **actual returned type** of a function literal as computed above.
Let `R` be the greatest closure of the typing context `K` as computed above. If
`T <: R` then let `S` be `T`. Otherwise, let `S` be `R`. The inferred return
type of the function literal is then defined as follows:
Let `R` be the greatest closure of the typing context `K` as computed above.
If `R` is `void`, or the function literal is marked `async` and `R` is
`FutureOr<void>`, let `S` be `void`. Otherwise, if `T <: R` then let `S` be
`T`. Otherwise, let `S` be `R`. The inferred return type of the function
literal is then defined as follows:
- If the function literal is marked `async` then the inferred return type is
`Future<flatten(S)>`.
- If the function literal is marked `async*` then the inferred return type is
Expand Down