Skip to content

Commit 79b9fa5

Browse files
Andysandersn
authored andcommitted
Avoid infinite loop checking yield expression (#21728)
* Avoid infinite loop checking yield expression * Revert now-unneeded change * Revert test filename changes
1 parent ca7f78b commit 79b9fa5

File tree

4 files changed

+57
-0
lines changed

4 files changed

+57
-0
lines changed
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
//// [yieldExpressionInFlowLoop.ts]
2+
function* f() {
3+
let result;
4+
while (1) {
5+
result = yield result;
6+
}
7+
}
8+
9+
10+
//// [yieldExpressionInFlowLoop.js]
11+
function* f() {
12+
let result;
13+
while (1) {
14+
result = yield result;
15+
}
16+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
=== tests/cases/compiler/yieldExpressionInFlowLoop.ts ===
2+
function* f() {
3+
>f : Symbol(f, Decl(yieldExpressionInFlowLoop.ts, 0, 0))
4+
5+
let result;
6+
>result : Symbol(result, Decl(yieldExpressionInFlowLoop.ts, 1, 7))
7+
8+
while (1) {
9+
result = yield result;
10+
>result : Symbol(result, Decl(yieldExpressionInFlowLoop.ts, 1, 7))
11+
>result : Symbol(result, Decl(yieldExpressionInFlowLoop.ts, 1, 7))
12+
}
13+
}
14+
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
=== tests/cases/compiler/yieldExpressionInFlowLoop.ts ===
2+
function* f() {
3+
>f : () => IterableIterator<any>
4+
5+
let result;
6+
>result : any
7+
8+
while (1) {
9+
>1 : 1
10+
11+
result = yield result;
12+
>result = yield result : any
13+
>result : any
14+
>yield result : any
15+
>result : any
16+
}
17+
}
18+
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
// @noImplicitAny: true
2+
// @target: es6
3+
4+
function* f() {
5+
let result;
6+
while (1) {
7+
result = yield result;
8+
}
9+
}

0 commit comments

Comments
 (0)