Skip to content

Commit 2a8bff5

Browse files
authored
Make function literal return type inference infer void from context (#1092)
2 parents d69beaf + 30494d2 commit 2a8bff5

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

resources/type-system/inference.md

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ Status: Draft
66

77
## CHANGELOG
88

9+
2020.07.14:
10+
- Infer return type `void` from context with function literals.
11+
912
2020.06.04:
1013
- Make conflict resolution for override inference explicit.
1114

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

320323
Let `T` be the **actual returned type** of a function literal as computed above.
321-
Let `R` be the greatest closure of the typing context `K` as computed above. If
322-
`T <: R` then let `S` be `T`. Otherwise, let `S` be `R`. The inferred return
323-
type of the function literal is then defined as follows:
324+
Let `R` be the greatest closure of the typing context `K` as computed above.
325+
If `R` is `void`, or the function literal is marked `async` and `R` is
326+
`FutureOr<void>`, let `S` be `void`. Otherwise, if `T <: R` then let `S` be
327+
`T`. Otherwise, let `S` be `R`. The inferred return type of the function
328+
literal is then defined as follows:
324329
- If the function literal is marked `async` then the inferred return type is
325330
`Future<flatten(S)>`.
326331
- If the function literal is marked `async*` then the inferred return type is

0 commit comments

Comments
 (0)