Skip to content

Commit 702de1e

Browse files
authoredOct 25, 2022
Fix early call to return/throw on generator (#51294)
1 parent 2c12b14 commit 702de1e

File tree

68 files changed

+134
-98
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

68 files changed

+134
-98
lines changed
 

‎src/compiler/factory/emitHelpers.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -705,6 +705,8 @@ namespace ts {
705705
// - The verb (`next`, `throw`, or `return` method) to delegate to the expression
706706
// of a `yield*`.
707707
// - The result of evaluating the verb delegated to the expression of a `yield*`.
708+
// g A temporary variable that holds onto the generator object until the generator
709+
// is started, allowing it to also act as the `suspendedStart` state.
708710
//
709711
// functions:
710712
// verb(n) Creates a bound callback to the `step` function for opcode `n`.
@@ -750,7 +752,7 @@ namespace ts {
750752
function verb(n) { return function (v) { return step([n, v]); }; }
751753
function step(op) {
752754
if (f) throw new TypeError("Generator is already executing.");
753-
while (_) try {
755+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
754756
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
755757
if (y = 0, t) op = [op[0] & 2, t.value];
756758
switch (op[0]) {

‎src/testRunner/tsconfig.json

+1
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@
9696
"unittests/evaluation/externalModules.ts",
9797
"unittests/evaluation/forAwaitOf.ts",
9898
"unittests/evaluation/forOf.ts",
99+
"unittests/evaluation/generator.ts",
99100
"unittests/evaluation/optionalCall.ts",
100101
"unittests/evaluation/objectRest.ts",
101102
"unittests/evaluation/superInStaticInitializer.ts",

0 commit comments

Comments
 (0)
Please sign in to comment.