Skip to content

Commit 149f0d2

Browse files
committed
Adjust function literal return type inference to avoid spurious null
1 parent d1e361e commit 149f0d2

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

resources/type-system/inference.md

+7-1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,11 @@ Status: Draft
66

77
## CHANGELOG
88

9+
2024.12.17
10+
- Change the function literal return type inference rules to ignore
11+
`return;` statements in generators (it doesn't actually cause null to be
12+
returned).
13+
914
2022.05.12
1015
- Define the notions of "constraint solution for a set of type variables" and
1116
"Grounded constraint solution for a set of type variables". These
@@ -324,7 +329,8 @@ schema.
324329
`e`, using the local type inference algorithm described below with typing
325330
context `K`, and update `T` to be `UP(flatten(S), T)` if the enclosing
326331
function is `async`, or `UP(S, T)` otherwise.
327-
- For each `return;` statement in the block, update `T` to be `UP(Null, T)`.
332+
- If the enclosing function is not marked `sync*` or `async*`: For each
333+
`return;` statement in the block, update `T` to be `UP(Null, T)`.
328334
- For each `yield e;` statement in the block, let `S` be the inferred type of
329335
`e`, using the local type inference algorithm described below with typing
330336
context `K`, and update `T` to be `UP(S, T)`.

0 commit comments

Comments
 (0)