mirror of
https://github.com/microsoft/TypeScript.git
synced 2025-11-18 17:21:48 +00:00
Ensure call return() for an abrupt completion at for await of loop (#52754)
Co-authored-by: tm-kwon <tm.kwon@naverlabs.com>
This commit is contained in:
@@ -767,11 +767,7 @@ export function transformES2018(context: TransformationContext): (x: SourceFile
|
||||
const exitNonUserCodeStatement = factory.createExpressionStatement(exitNonUserCodeExpression);
|
||||
setSourceMapRange(exitNonUserCodeStatement, node.expression);
|
||||
|
||||
const enterNonUserCodeExpression = factory.createAssignment(nonUserCode, factory.createTrue());
|
||||
const enterNonUserCodeStatement = factory.createExpressionStatement(enterNonUserCodeExpression);
|
||||
setSourceMapRange(exitNonUserCodeStatement, node.expression);
|
||||
|
||||
const statements: Statement[] = [];
|
||||
const statements: Statement[] = [iteratorValueStatement, exitNonUserCodeStatement];
|
||||
const binding = createForOfBindingStatement(factory, node.initializer, value);
|
||||
statements.push(visitNode(binding, visitor, isStatement));
|
||||
|
||||
@@ -787,28 +783,13 @@ export function transformES2018(context: TransformationContext): (x: SourceFile
|
||||
statements.push(statement);
|
||||
}
|
||||
|
||||
const body = setEmitFlags(
|
||||
setTextRange(
|
||||
factory.createBlock(
|
||||
setTextRange(factory.createNodeArray(statements), statementsLocation),
|
||||
/*multiLine*/ true
|
||||
),
|
||||
bodyLocation
|
||||
return setTextRange(
|
||||
factory.createBlock(
|
||||
setTextRange(factory.createNodeArray(statements), statementsLocation),
|
||||
/*multiLine*/ true
|
||||
),
|
||||
EmitFlags.NoSourceMap | EmitFlags.NoTokenSourceMaps
|
||||
bodyLocation
|
||||
);
|
||||
|
||||
return factory.createBlock([
|
||||
iteratorValueStatement,
|
||||
exitNonUserCodeStatement,
|
||||
factory.createTryStatement(
|
||||
body,
|
||||
/*catchClause*/ undefined,
|
||||
factory.createBlock([
|
||||
enterNonUserCodeStatement
|
||||
])
|
||||
)
|
||||
]);
|
||||
}
|
||||
|
||||
function createDownlevelAwait(expression: Expression) {
|
||||
@@ -859,7 +840,7 @@ export function transformES2018(context: TransformationContext): (x: SourceFile
|
||||
factory.createAssignment(done, getDone),
|
||||
factory.createLogicalNot(done)
|
||||
]),
|
||||
/*incrementor*/ undefined,
|
||||
/*incrementor*/ factory.createAssignment(nonUserCode, factory.createTrue()),
|
||||
/*statement*/ convertForOfStatementHead(node, getValue, nonUserCode)
|
||||
),
|
||||
/*location*/ node
|
||||
|
||||
@@ -106,6 +106,81 @@ describe("unittests:: evaluation:: forAwaitOfEvaluation", () => {
|
||||
assert.instanceOf(result.output[2], Promise);
|
||||
});
|
||||
|
||||
it("call return when user code return (es2015)", async () => {
|
||||
const result = evaluator.evaluateTypeScript(`
|
||||
let returnCalled = false;
|
||||
async function f() {
|
||||
const iterator = {
|
||||
[Symbol.asyncIterator](): AsyncIterableIterator<any> { return this; },
|
||||
async next() {
|
||||
return { value: undefined, done: false };
|
||||
},
|
||||
async return() {
|
||||
returnCalled = true;
|
||||
}
|
||||
};
|
||||
for await (const item of iterator) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
export async function main() {
|
||||
try { await f(); } catch { }
|
||||
return returnCalled;
|
||||
}
|
||||
`, { target: ts.ScriptTarget.ES2015 });
|
||||
assert.isTrue(await result.main());
|
||||
});
|
||||
|
||||
it("call return when user code break (es2015)", async () => {
|
||||
const result = evaluator.evaluateTypeScript(`
|
||||
let returnCalled = false;
|
||||
async function f() {
|
||||
const iterator = {
|
||||
[Symbol.asyncIterator](): AsyncIterableIterator<any> { return this; },
|
||||
async next() {
|
||||
return { value: undefined, done: false };
|
||||
},
|
||||
async return() {
|
||||
returnCalled = true;
|
||||
}
|
||||
};
|
||||
for await (const item of iterator) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
export async function main() {
|
||||
try { await f(); } catch { }
|
||||
return returnCalled;
|
||||
}
|
||||
`, { target: ts.ScriptTarget.ES2015 });
|
||||
assert.isTrue(await result.main());
|
||||
});
|
||||
|
||||
it("call return when user code throws (es2015)", async () => {
|
||||
const result = evaluator.evaluateTypeScript(`
|
||||
let returnCalled = false;
|
||||
async function f() {
|
||||
const iterator = {
|
||||
[Symbol.asyncIterator](): AsyncIterableIterator<any> { return this; },
|
||||
async next() {
|
||||
return { value: undefined, done: false };
|
||||
},
|
||||
async return() {
|
||||
returnCalled = true;
|
||||
}
|
||||
};
|
||||
for await (const item of iterator) {
|
||||
throw new Error();
|
||||
}
|
||||
}
|
||||
export async function main() {
|
||||
try { await f(); } catch { }
|
||||
return returnCalled;
|
||||
}
|
||||
`, { target: ts.ScriptTarget.ES2015 });
|
||||
assert.isTrue(await result.main());
|
||||
});
|
||||
|
||||
it("don't call return when non-user code throws (es2015)", async () => {
|
||||
const result = evaluator.evaluateTypeScript(`
|
||||
let returnCalled = false;
|
||||
@@ -132,4 +207,96 @@ describe("unittests:: evaluation:: forAwaitOfEvaluation", () => {
|
||||
`, { target: ts.ScriptTarget.ES2015 });
|
||||
assert.isFalse(await result.main());
|
||||
});
|
||||
|
||||
it("don't call return when user code continue (es2015)", async () => {
|
||||
const result = evaluator.evaluateTypeScript(`
|
||||
let returnCalled = false;
|
||||
async function f() {
|
||||
let i = 0;
|
||||
const iterator = {
|
||||
[Symbol.asyncIterator](): AsyncIterableIterator<any> { return this; },
|
||||
async next() {
|
||||
i++;
|
||||
if (i < 2) return { value: undefined, done: false };
|
||||
throw new Error();
|
||||
},
|
||||
async return() {
|
||||
returnCalled = true;
|
||||
}
|
||||
};
|
||||
for await (const item of iterator) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
export async function main() {
|
||||
try { await f(); } catch { }
|
||||
return returnCalled;
|
||||
}
|
||||
`, { target: ts.ScriptTarget.ES2015 });
|
||||
assert.isFalse(await result.main());
|
||||
});
|
||||
|
||||
it("don't call return when user code continue to local label (es2015)", async () => {
|
||||
const result = evaluator.evaluateTypeScript(`
|
||||
let returnCalled = false;
|
||||
async function f() {
|
||||
let i = 0;
|
||||
const iterator = {
|
||||
[Symbol.asyncIterator](): AsyncIterableIterator<any> { return this; },
|
||||
async next() {
|
||||
i++;
|
||||
if (i < 2) return { value: undefined, done: false };
|
||||
throw new Error();
|
||||
},
|
||||
async return() {
|
||||
returnCalled = true;
|
||||
}
|
||||
};
|
||||
outerLoop:
|
||||
for (const outerItem of [1, 2, 3]) {
|
||||
innerLoop:
|
||||
for await (const item of iterator) {
|
||||
continue innerLoop;
|
||||
}
|
||||
}
|
||||
}
|
||||
export async function main() {
|
||||
try { await f(); } catch { }
|
||||
return returnCalled;
|
||||
}
|
||||
`, { target: ts.ScriptTarget.ES2015 });
|
||||
assert.isFalse(await result.main());
|
||||
});
|
||||
|
||||
it("call return when user code continue to non-local label (es2015)", async () => {
|
||||
const result = evaluator.evaluateTypeScript(`
|
||||
let returnCalled = false;
|
||||
async function f() {
|
||||
let i = 0;
|
||||
const iterator = {
|
||||
[Symbol.asyncIterator](): AsyncIterableIterator<any> { return this; },
|
||||
async next() {
|
||||
i++;
|
||||
if (i < 2) return { value: undefined, done: false };
|
||||
return { value: undefined, done: true };
|
||||
},
|
||||
async return() {
|
||||
returnCalled = true;
|
||||
}
|
||||
};
|
||||
outerLoop:
|
||||
for (const outerItem of [1, 2, 3]) {
|
||||
innerLoop:
|
||||
for await (const item of iterator) {
|
||||
continue outerLoop;
|
||||
}
|
||||
}
|
||||
}
|
||||
export async function main() {
|
||||
try { await f(); } catch { }
|
||||
return returnCalled;
|
||||
}
|
||||
`, { target: ts.ScriptTarget.ES2015 });
|
||||
assert.isTrue(await result.main());
|
||||
});
|
||||
});
|
||||
|
||||
@@ -72,15 +72,10 @@ function f1() {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
let y;
|
||||
try {
|
||||
for (var _d = true, y_1 = __asyncValues(y), y_1_1; y_1_1 = yield y_1.next(), _a = y_1_1.done, !_a;) {
|
||||
for (var _d = true, y_1 = __asyncValues(y), y_1_1; y_1_1 = yield y_1.next(), _a = y_1_1.done, !_a; _d = true) {
|
||||
_c = y_1_1.value;
|
||||
_d = false;
|
||||
try {
|
||||
const x = _c;
|
||||
}
|
||||
finally {
|
||||
_d = true;
|
||||
}
|
||||
const x = _c;
|
||||
}
|
||||
}
|
||||
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
||||
@@ -114,15 +109,10 @@ function f2() {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
let x, y;
|
||||
try {
|
||||
for (var _d = true, y_1 = __asyncValues(y), y_1_1; y_1_1 = yield y_1.next(), _a = y_1_1.done, !_a;) {
|
||||
for (var _d = true, y_1 = __asyncValues(y), y_1_1; y_1_1 = yield y_1.next(), _a = y_1_1.done, !_a; _d = true) {
|
||||
_c = y_1_1.value;
|
||||
_d = false;
|
||||
try {
|
||||
x = _c;
|
||||
}
|
||||
finally {
|
||||
_d = true;
|
||||
}
|
||||
x = _c;
|
||||
}
|
||||
}
|
||||
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
||||
@@ -159,15 +149,10 @@ function f3() {
|
||||
var _a, e_1, _b, _c;
|
||||
let y;
|
||||
try {
|
||||
for (var _d = true, y_1 = __asyncValues(y), y_1_1; y_1_1 = yield __await(y_1.next()), _a = y_1_1.done, !_a;) {
|
||||
for (var _d = true, y_1 = __asyncValues(y), y_1_1; y_1_1 = yield __await(y_1.next()), _a = y_1_1.done, !_a; _d = true) {
|
||||
_c = y_1_1.value;
|
||||
_d = false;
|
||||
try {
|
||||
const x = _c;
|
||||
}
|
||||
finally {
|
||||
_d = true;
|
||||
}
|
||||
const x = _c;
|
||||
}
|
||||
}
|
||||
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
||||
@@ -204,15 +189,10 @@ function f4() {
|
||||
var _a, e_1, _b, _c;
|
||||
let x, y;
|
||||
try {
|
||||
for (var _d = true, y_1 = __asyncValues(y), y_1_1; y_1_1 = yield __await(y_1.next()), _a = y_1_1.done, !_a;) {
|
||||
for (var _d = true, y_1 = __asyncValues(y), y_1_1; y_1_1 = yield __await(y_1.next()), _a = y_1_1.done, !_a; _d = true) {
|
||||
_c = y_1_1.value;
|
||||
_d = false;
|
||||
try {
|
||||
x = _c;
|
||||
}
|
||||
finally {
|
||||
_d = true;
|
||||
}
|
||||
x = _c;
|
||||
}
|
||||
}
|
||||
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
||||
@@ -247,16 +227,11 @@ function f5() {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
let y;
|
||||
try {
|
||||
outer: for (var _d = true, y_1 = __asyncValues(y), y_1_1; y_1_1 = yield y_1.next(), _a = y_1_1.done, !_a;) {
|
||||
outer: for (var _d = true, y_1 = __asyncValues(y), y_1_1; y_1_1 = yield y_1.next(), _a = y_1_1.done, !_a; _d = true) {
|
||||
_c = y_1_1.value;
|
||||
_d = false;
|
||||
try {
|
||||
const x = _c;
|
||||
continue outer;
|
||||
}
|
||||
finally {
|
||||
_d = true;
|
||||
}
|
||||
const x = _c;
|
||||
continue outer;
|
||||
}
|
||||
}
|
||||
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
||||
@@ -294,16 +269,11 @@ function f6() {
|
||||
var _a, e_1, _b, _c;
|
||||
let y;
|
||||
try {
|
||||
outer: for (var _d = true, y_1 = __asyncValues(y), y_1_1; y_1_1 = yield __await(y_1.next()), _a = y_1_1.done, !_a;) {
|
||||
outer: for (var _d = true, y_1 = __asyncValues(y), y_1_1; y_1_1 = yield __await(y_1.next()), _a = y_1_1.done, !_a; _d = true) {
|
||||
_c = y_1_1.value;
|
||||
_d = false;
|
||||
try {
|
||||
const x = _c;
|
||||
continue outer;
|
||||
}
|
||||
finally {
|
||||
_d = true;
|
||||
}
|
||||
const x = _c;
|
||||
continue outer;
|
||||
}
|
||||
}
|
||||
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
||||
@@ -342,15 +312,10 @@ function f7() {
|
||||
let y;
|
||||
for (;;) {
|
||||
try {
|
||||
for (var _d = true, y_1 = (e_1 = void 0, __asyncValues(y)), y_1_1; y_1_1 = yield __await(y_1.next()), _a = y_1_1.done, !_a;) {
|
||||
for (var _d = true, y_1 = (e_1 = void 0, __asyncValues(y)), y_1_1; y_1_1 = yield __await(y_1.next()), _a = y_1_1.done, !_a; _d = true) {
|
||||
_c = y_1_1.value;
|
||||
_d = false;
|
||||
try {
|
||||
const x = _c;
|
||||
}
|
||||
finally {
|
||||
_d = true;
|
||||
}
|
||||
const x = _c;
|
||||
}
|
||||
}
|
||||
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
||||
|
||||
@@ -62,15 +62,10 @@ async function f1() {
|
||||
var _a, e_1, _b, _c;
|
||||
let y;
|
||||
try {
|
||||
for (var _d = true, y_1 = __asyncValues(y), y_1_1; y_1_1 = await y_1.next(), _a = y_1_1.done, !_a;) {
|
||||
for (var _d = true, y_1 = __asyncValues(y), y_1_1; y_1_1 = await y_1.next(), _a = y_1_1.done, !_a; _d = true) {
|
||||
_c = y_1_1.value;
|
||||
_d = false;
|
||||
try {
|
||||
const x = _c;
|
||||
}
|
||||
finally {
|
||||
_d = true;
|
||||
}
|
||||
const x = _c;
|
||||
}
|
||||
}
|
||||
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
||||
@@ -93,15 +88,10 @@ async function f2() {
|
||||
var _a, e_1, _b, _c;
|
||||
let x, y;
|
||||
try {
|
||||
for (var _d = true, y_1 = __asyncValues(y), y_1_1; y_1_1 = await y_1.next(), _a = y_1_1.done, !_a;) {
|
||||
for (var _d = true, y_1 = __asyncValues(y), y_1_1; y_1_1 = await y_1.next(), _a = y_1_1.done, !_a; _d = true) {
|
||||
_c = y_1_1.value;
|
||||
_d = false;
|
||||
try {
|
||||
x = _c;
|
||||
}
|
||||
finally {
|
||||
_d = true;
|
||||
}
|
||||
x = _c;
|
||||
}
|
||||
}
|
||||
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
||||
@@ -137,15 +127,10 @@ function f3() {
|
||||
var _a, e_1, _b, _c;
|
||||
let y;
|
||||
try {
|
||||
for (var _d = true, y_1 = __asyncValues(y), y_1_1; y_1_1 = yield __await(y_1.next()), _a = y_1_1.done, !_a;) {
|
||||
for (var _d = true, y_1 = __asyncValues(y), y_1_1; y_1_1 = yield __await(y_1.next()), _a = y_1_1.done, !_a; _d = true) {
|
||||
_c = y_1_1.value;
|
||||
_d = false;
|
||||
try {
|
||||
const x = _c;
|
||||
}
|
||||
finally {
|
||||
_d = true;
|
||||
}
|
||||
const x = _c;
|
||||
}
|
||||
}
|
||||
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
||||
@@ -182,15 +167,10 @@ function f4() {
|
||||
var _a, e_1, _b, _c;
|
||||
let x, y;
|
||||
try {
|
||||
for (var _d = true, y_1 = __asyncValues(y), y_1_1; y_1_1 = yield __await(y_1.next()), _a = y_1_1.done, !_a;) {
|
||||
for (var _d = true, y_1 = __asyncValues(y), y_1_1; y_1_1 = yield __await(y_1.next()), _a = y_1_1.done, !_a; _d = true) {
|
||||
_c = y_1_1.value;
|
||||
_d = false;
|
||||
try {
|
||||
x = _c;
|
||||
}
|
||||
finally {
|
||||
_d = true;
|
||||
}
|
||||
x = _c;
|
||||
}
|
||||
}
|
||||
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
||||
@@ -215,16 +195,11 @@ async function f5() {
|
||||
var _a, e_1, _b, _c;
|
||||
let y;
|
||||
try {
|
||||
outer: for (var _d = true, y_1 = __asyncValues(y), y_1_1; y_1_1 = await y_1.next(), _a = y_1_1.done, !_a;) {
|
||||
outer: for (var _d = true, y_1 = __asyncValues(y), y_1_1; y_1_1 = await y_1.next(), _a = y_1_1.done, !_a; _d = true) {
|
||||
_c = y_1_1.value;
|
||||
_d = false;
|
||||
try {
|
||||
const x = _c;
|
||||
continue outer;
|
||||
}
|
||||
finally {
|
||||
_d = true;
|
||||
}
|
||||
const x = _c;
|
||||
continue outer;
|
||||
}
|
||||
}
|
||||
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
||||
@@ -261,16 +236,11 @@ function f6() {
|
||||
var _a, e_1, _b, _c;
|
||||
let y;
|
||||
try {
|
||||
outer: for (var _d = true, y_1 = __asyncValues(y), y_1_1; y_1_1 = yield __await(y_1.next()), _a = y_1_1.done, !_a;) {
|
||||
outer: for (var _d = true, y_1 = __asyncValues(y), y_1_1; y_1_1 = yield __await(y_1.next()), _a = y_1_1.done, !_a; _d = true) {
|
||||
_c = y_1_1.value;
|
||||
_d = false;
|
||||
try {
|
||||
const x = _c;
|
||||
continue outer;
|
||||
}
|
||||
finally {
|
||||
_d = true;
|
||||
}
|
||||
const x = _c;
|
||||
continue outer;
|
||||
}
|
||||
}
|
||||
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
||||
@@ -309,15 +279,10 @@ function f7() {
|
||||
let y;
|
||||
for (;;) {
|
||||
try {
|
||||
for (var _d = true, y_1 = (e_1 = void 0, __asyncValues(y)), y_1_1; y_1_1 = yield __await(y_1.next()), _a = y_1_1.done, !_a;) {
|
||||
for (var _d = true, y_1 = (e_1 = void 0, __asyncValues(y)), y_1_1; y_1_1 = yield __await(y_1.next()), _a = y_1_1.done, !_a; _d = true) {
|
||||
_c = y_1_1.value;
|
||||
_d = false;
|
||||
try {
|
||||
const x = _c;
|
||||
}
|
||||
finally {
|
||||
_d = true;
|
||||
}
|
||||
const x = _c;
|
||||
}
|
||||
}
|
||||
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
||||
|
||||
@@ -109,14 +109,11 @@ function f1() {
|
||||
if (!(y_1_1 = _e.sent(), _a = y_1_1.done, !_a)) return [3 /*break*/, 4];
|
||||
_c = y_1_1.value;
|
||||
_d = false;
|
||||
try {
|
||||
x = _c;
|
||||
}
|
||||
finally {
|
||||
_d = true;
|
||||
}
|
||||
x = _c;
|
||||
_e.label = 3;
|
||||
case 3: return [3 /*break*/, 1];
|
||||
case 3:
|
||||
_d = true;
|
||||
return [3 /*break*/, 1];
|
||||
case 4: return [3 /*break*/, 11];
|
||||
case 5:
|
||||
e_1_1 = _e.sent();
|
||||
@@ -198,14 +195,11 @@ function f2() {
|
||||
if (!(y_1_1 = _e.sent(), _a = y_1_1.done, !_a)) return [3 /*break*/, 4];
|
||||
_c = y_1_1.value;
|
||||
_d = false;
|
||||
try {
|
||||
x = _c;
|
||||
}
|
||||
finally {
|
||||
_d = true;
|
||||
}
|
||||
x = _c;
|
||||
_e.label = 3;
|
||||
case 3: return [3 /*break*/, 1];
|
||||
case 3:
|
||||
_d = true;
|
||||
return [3 /*break*/, 1];
|
||||
case 4: return [3 /*break*/, 11];
|
||||
case 5:
|
||||
e_1_1 = _e.sent();
|
||||
@@ -290,14 +284,11 @@ function f3() {
|
||||
if (!(y_1_1 = _e.sent(), _b = y_1_1.done, !_b)) return [3 /*break*/, 4];
|
||||
_d = y_1_1.value;
|
||||
_a = false;
|
||||
try {
|
||||
x = _d;
|
||||
}
|
||||
finally {
|
||||
_a = true;
|
||||
}
|
||||
x = _d;
|
||||
_e.label = 3;
|
||||
case 3: return [3 /*break*/, 1];
|
||||
case 3:
|
||||
_a = true;
|
||||
return [3 /*break*/, 1];
|
||||
case 4: return [3 /*break*/, 11];
|
||||
case 5:
|
||||
e_1_1 = _e.sent();
|
||||
@@ -382,14 +373,11 @@ function f4() {
|
||||
if (!(y_1_1 = _e.sent(), _b = y_1_1.done, !_b)) return [3 /*break*/, 4];
|
||||
_d = y_1_1.value;
|
||||
_a = false;
|
||||
try {
|
||||
x = _d;
|
||||
}
|
||||
finally {
|
||||
_a = true;
|
||||
}
|
||||
x = _d;
|
||||
_e.label = 3;
|
||||
case 3: return [3 /*break*/, 1];
|
||||
case 3:
|
||||
_a = true;
|
||||
return [3 /*break*/, 1];
|
||||
case 4: return [3 /*break*/, 11];
|
||||
case 5:
|
||||
e_1_1 = _e.sent();
|
||||
@@ -472,15 +460,11 @@ function f5() {
|
||||
if (!(y_1_1 = _e.sent(), _a = y_1_1.done, !_a)) return [3 /*break*/, 4];
|
||||
_c = y_1_1.value;
|
||||
_d = false;
|
||||
try {
|
||||
x = _c;
|
||||
return [3 /*break*/, 3];
|
||||
}
|
||||
finally {
|
||||
_d = true;
|
||||
}
|
||||
_e.label = 3;
|
||||
case 3: return [3 /*break*/, 1];
|
||||
x = _c;
|
||||
return [3 /*break*/, 3];
|
||||
case 3:
|
||||
_d = true;
|
||||
return [3 /*break*/, 1];
|
||||
case 4: return [3 /*break*/, 11];
|
||||
case 5:
|
||||
e_1_1 = _e.sent();
|
||||
@@ -566,15 +550,11 @@ function f6() {
|
||||
if (!(y_1_1 = _e.sent(), _b = y_1_1.done, !_b)) return [3 /*break*/, 4];
|
||||
_d = y_1_1.value;
|
||||
_a = false;
|
||||
try {
|
||||
x = _d;
|
||||
return [3 /*break*/, 3];
|
||||
}
|
||||
finally {
|
||||
_a = true;
|
||||
}
|
||||
_e.label = 3;
|
||||
case 3: return [3 /*break*/, 1];
|
||||
x = _d;
|
||||
return [3 /*break*/, 3];
|
||||
case 3:
|
||||
_a = true;
|
||||
return [3 /*break*/, 1];
|
||||
case 4: return [3 /*break*/, 11];
|
||||
case 5:
|
||||
e_1_1 = _e.sent();
|
||||
@@ -660,14 +640,11 @@ function f7() {
|
||||
if (!(y_1_1 = _e.sent(), _b = y_1_1.done, !_b)) return [3 /*break*/, 4];
|
||||
_d = y_1_1.value;
|
||||
_a = false;
|
||||
try {
|
||||
x = _d;
|
||||
}
|
||||
finally {
|
||||
_a = true;
|
||||
}
|
||||
x = _d;
|
||||
_e.label = 3;
|
||||
case 3: return [3 /*break*/, 1];
|
||||
case 3:
|
||||
_a = true;
|
||||
return [3 /*break*/, 1];
|
||||
case 4: return [3 /*break*/, 11];
|
||||
case 5:
|
||||
e_1_1 = _e.sent();
|
||||
|
||||
@@ -114,32 +114,27 @@ var log = console.log;
|
||||
_loop_1 = function () {
|
||||
_f = _c.value;
|
||||
_a = false;
|
||||
try {
|
||||
var outer = _f;
|
||||
log("I'm loop ".concat(outer));
|
||||
(function () { return __awaiter(_this, void 0, void 0, function () {
|
||||
var inner;
|
||||
return __generator(this, function (_a) {
|
||||
switch (_a.label) {
|
||||
case 0:
|
||||
inner = outer;
|
||||
return [4 /*yield*/, sleep(2000)];
|
||||
case 1:
|
||||
_a.sent();
|
||||
if (inner === outer) {
|
||||
log("I'm loop ".concat(inner, " and I know I'm loop ").concat(outer));
|
||||
}
|
||||
else {
|
||||
log("I'm loop ".concat(inner, ", but I think I'm loop ").concat(outer));
|
||||
}
|
||||
return [2 /*return*/];
|
||||
}
|
||||
});
|
||||
}); })();
|
||||
}
|
||||
finally {
|
||||
_a = true;
|
||||
}
|
||||
var outer = _f;
|
||||
log("I'm loop ".concat(outer));
|
||||
(function () { return __awaiter(_this, void 0, void 0, function () {
|
||||
var inner;
|
||||
return __generator(this, function (_a) {
|
||||
switch (_a.label) {
|
||||
case 0:
|
||||
inner = outer;
|
||||
return [4 /*yield*/, sleep(2000)];
|
||||
case 1:
|
||||
_a.sent();
|
||||
if (inner === outer) {
|
||||
log("I'm loop ".concat(inner, " and I know I'm loop ").concat(outer));
|
||||
}
|
||||
else {
|
||||
log("I'm loop ".concat(inner, ", but I think I'm loop ").concat(outer));
|
||||
}
|
||||
return [2 /*return*/];
|
||||
}
|
||||
});
|
||||
}); })();
|
||||
};
|
||||
_a = true, _b = __asyncValues(gen());
|
||||
_g.label = 1;
|
||||
@@ -148,7 +143,9 @@ var log = console.log;
|
||||
if (!(_c = _g.sent(), _d = _c.done, !_d)) return [3 /*break*/, 4];
|
||||
_loop_1();
|
||||
_g.label = 3;
|
||||
case 3: return [3 /*break*/, 1];
|
||||
case 3:
|
||||
_a = true;
|
||||
return [3 /*break*/, 1];
|
||||
case 4: return [3 /*break*/, 11];
|
||||
case 5:
|
||||
e_1_1 = _g.sent();
|
||||
|
||||
@@ -37,15 +37,10 @@ exports.x = void 0;
|
||||
var x = await 1;
|
||||
exports.x = x;
|
||||
try {
|
||||
for (var _d = true, _e = __asyncValues([]), _f; _f = await _e.next(), _a = _f.done, !_a;) {
|
||||
for (var _d = true, _e = __asyncValues([]), _f; _f = await _e.next(), _a = _f.done, !_a; _d = true) {
|
||||
_c = _f.value;
|
||||
_d = false;
|
||||
try {
|
||||
var y = _c;
|
||||
}
|
||||
finally {
|
||||
_d = true;
|
||||
}
|
||||
var y = _c;
|
||||
}
|
||||
}
|
||||
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
||||
@@ -68,15 +63,10 @@ var _a, e_1, _b, _c;
|
||||
var x = await 1;
|
||||
export { x };
|
||||
try {
|
||||
for (var _d = true, _e = __asyncValues([]), _f; _f = await _e.next(), _a = _f.done, !_a;) {
|
||||
for (var _d = true, _e = __asyncValues([]), _f; _f = await _e.next(), _a = _f.done, !_a; _d = true) {
|
||||
_c = _f.value;
|
||||
_d = false;
|
||||
try {
|
||||
var y = _c;
|
||||
}
|
||||
finally {
|
||||
_d = true;
|
||||
}
|
||||
var y = _c;
|
||||
}
|
||||
}
|
||||
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
||||
|
||||
@@ -37,15 +37,10 @@ exports.x = void 0;
|
||||
var x = await 1;
|
||||
exports.x = x;
|
||||
try {
|
||||
for (var _d = true, _e = __asyncValues([]), _f; _f = await _e.next(), _a = _f.done, !_a;) {
|
||||
for (var _d = true, _e = __asyncValues([]), _f; _f = await _e.next(), _a = _f.done, !_a; _d = true) {
|
||||
_c = _f.value;
|
||||
_d = false;
|
||||
try {
|
||||
var y = _c;
|
||||
}
|
||||
finally {
|
||||
_d = true;
|
||||
}
|
||||
var y = _c;
|
||||
}
|
||||
}
|
||||
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
||||
@@ -68,15 +63,10 @@ var _a, e_1, _b, _c;
|
||||
var x = await 1;
|
||||
export { x };
|
||||
try {
|
||||
for (var _d = true, _e = __asyncValues([]), _f; _f = await _e.next(), _a = _f.done, !_a;) {
|
||||
for (var _d = true, _e = __asyncValues([]), _f; _f = await _e.next(), _a = _f.done, !_a; _d = true) {
|
||||
_c = _f.value;
|
||||
_d = false;
|
||||
try {
|
||||
var y = _c;
|
||||
}
|
||||
finally {
|
||||
_d = true;
|
||||
}
|
||||
var y = _c;
|
||||
}
|
||||
}
|
||||
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
||||
|
||||
@@ -37,15 +37,10 @@ exports.x = void 0;
|
||||
var x = await 1;
|
||||
exports.x = x;
|
||||
try {
|
||||
for (var _d = true, _e = __asyncValues([]), _f; _f = await _e.next(), _a = _f.done, !_a;) {
|
||||
for (var _d = true, _e = __asyncValues([]), _f; _f = await _e.next(), _a = _f.done, !_a; _d = true) {
|
||||
_c = _f.value;
|
||||
_d = false;
|
||||
try {
|
||||
var y = _c;
|
||||
}
|
||||
finally {
|
||||
_d = true;
|
||||
}
|
||||
var y = _c;
|
||||
}
|
||||
}
|
||||
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
||||
@@ -68,15 +63,10 @@ var _a, e_1, _b, _c;
|
||||
var x = await 1;
|
||||
export { x };
|
||||
try {
|
||||
for (var _d = true, _e = __asyncValues([]), _f; _f = await _e.next(), _a = _f.done, !_a;) {
|
||||
for (var _d = true, _e = __asyncValues([]), _f; _f = await _e.next(), _a = _f.done, !_a; _d = true) {
|
||||
_c = _f.value;
|
||||
_d = false;
|
||||
try {
|
||||
var y = _c;
|
||||
}
|
||||
finally {
|
||||
_d = true;
|
||||
}
|
||||
var y = _c;
|
||||
}
|
||||
}
|
||||
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
||||
|
||||
@@ -37,15 +37,10 @@ exports.x = void 0;
|
||||
var x = await 1;
|
||||
exports.x = x;
|
||||
try {
|
||||
for (var _d = true, _e = __asyncValues([]), _f; _f = await _e.next(), _a = _f.done, !_a;) {
|
||||
for (var _d = true, _e = __asyncValues([]), _f; _f = await _e.next(), _a = _f.done, !_a; _d = true) {
|
||||
_c = _f.value;
|
||||
_d = false;
|
||||
try {
|
||||
var y = _c;
|
||||
}
|
||||
finally {
|
||||
_d = true;
|
||||
}
|
||||
var y = _c;
|
||||
}
|
||||
}
|
||||
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
||||
@@ -68,15 +63,10 @@ var _a, e_1, _b, _c;
|
||||
var x = await 1;
|
||||
export { x };
|
||||
try {
|
||||
for (var _d = true, _e = __asyncValues([]), _f; _f = await _e.next(), _a = _f.done, !_a;) {
|
||||
for (var _d = true, _e = __asyncValues([]), _f; _f = await _e.next(), _a = _f.done, !_a; _d = true) {
|
||||
_c = _f.value;
|
||||
_d = false;
|
||||
try {
|
||||
var y = _c;
|
||||
}
|
||||
finally {
|
||||
_d = true;
|
||||
}
|
||||
var y = _c;
|
||||
}
|
||||
}
|
||||
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
||||
|
||||
@@ -114,14 +114,11 @@ function fn(a, b, c, d, e, f, g) {
|
||||
if (!(c_1_1 = _e.sent(), _b = c_1_1.done, !_b)) return [3 /*break*/, 5];
|
||||
_d = c_1_1.value;
|
||||
_a = false;
|
||||
try {
|
||||
s = _d;
|
||||
}
|
||||
finally {
|
||||
_a = true;
|
||||
}
|
||||
s = _d;
|
||||
_e.label = 4;
|
||||
case 4: return [3 /*break*/, 2];
|
||||
case 4:
|
||||
_a = true;
|
||||
return [3 /*break*/, 2];
|
||||
case 5: return [3 /*break*/, 12];
|
||||
case 6:
|
||||
e_1_1 = _e.sent();
|
||||
|
||||
@@ -88,16 +88,11 @@ export { _await as await };
|
||||
// for-await-of
|
||||
const arr = [Promise.resolve()];
|
||||
try {
|
||||
for (var _d = true, arr_1 = __asyncValues(arr), arr_1_1; arr_1_1 = await arr_1.next(), _a = arr_1_1.done, !_a;) {
|
||||
for (var _d = true, arr_1 = __asyncValues(arr), arr_1_1; arr_1_1 = await arr_1.next(), _a = arr_1_1.done, !_a; _d = true) {
|
||||
_c = arr_1_1.value;
|
||||
_d = false;
|
||||
try {
|
||||
const item = _c;
|
||||
item;
|
||||
}
|
||||
finally {
|
||||
_d = true;
|
||||
}
|
||||
const item = _c;
|
||||
item;
|
||||
}
|
||||
}
|
||||
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
||||
|
||||
@@ -88,16 +88,11 @@ export { _await as await };
|
||||
// for-await-of
|
||||
const arr = [Promise.resolve()];
|
||||
try {
|
||||
for (var _d = true, arr_1 = __asyncValues(arr), arr_1_1; arr_1_1 = await arr_1.next(), _a = arr_1_1.done, !_a;) {
|
||||
for (var _d = true, arr_1 = __asyncValues(arr), arr_1_1; arr_1_1 = await arr_1.next(), _a = arr_1_1.done, !_a; _d = true) {
|
||||
_c = arr_1_1.value;
|
||||
_d = false;
|
||||
try {
|
||||
const item = _c;
|
||||
item;
|
||||
}
|
||||
finally {
|
||||
_d = true;
|
||||
}
|
||||
const item = _c;
|
||||
item;
|
||||
}
|
||||
}
|
||||
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
||||
|
||||
@@ -88,16 +88,11 @@ export { _await as await };
|
||||
// for-await-of
|
||||
const arr = [Promise.resolve()];
|
||||
try {
|
||||
for (var _d = true, arr_1 = __asyncValues(arr), arr_1_1; arr_1_1 = await arr_1.next(), _a = arr_1_1.done, !_a;) {
|
||||
for (var _d = true, arr_1 = __asyncValues(arr), arr_1_1; arr_1_1 = await arr_1.next(), _a = arr_1_1.done, !_a; _d = true) {
|
||||
_c = arr_1_1.value;
|
||||
_d = false;
|
||||
try {
|
||||
const item = _c;
|
||||
item;
|
||||
}
|
||||
finally {
|
||||
_d = true;
|
||||
}
|
||||
const item = _c;
|
||||
item;
|
||||
}
|
||||
}
|
||||
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
||||
|
||||
@@ -88,16 +88,11 @@ export { _await as await };
|
||||
// for-await-of
|
||||
const arr = [Promise.resolve()];
|
||||
try {
|
||||
for (var _d = true, arr_1 = __asyncValues(arr), arr_1_1; arr_1_1 = await arr_1.next(), _a = arr_1_1.done, !_a;) {
|
||||
for (var _d = true, arr_1 = __asyncValues(arr), arr_1_1; arr_1_1 = await arr_1.next(), _a = arr_1_1.done, !_a; _d = true) {
|
||||
_c = arr_1_1.value;
|
||||
_d = false;
|
||||
try {
|
||||
const item = _c;
|
||||
item;
|
||||
}
|
||||
finally {
|
||||
_d = true;
|
||||
}
|
||||
const item = _c;
|
||||
item;
|
||||
}
|
||||
}
|
||||
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
||||
|
||||
@@ -93,16 +93,11 @@ System.register([], function (exports_1, context_1) {
|
||||
// for-await-of
|
||||
arr = [Promise.resolve()];
|
||||
try {
|
||||
for (var _a = true, arr_1 = __asyncValues(arr), arr_1_1; arr_1_1 = await arr_1.next(), _a = arr_1_1.done, !_a;) {
|
||||
for (var _a = true, arr_1 = __asyncValues(arr), arr_1_1; arr_1_1 = await arr_1.next(), _a = arr_1_1.done, !_a; _a = true) {
|
||||
_c = arr_1_1.value;
|
||||
_a = false;
|
||||
try {
|
||||
const item = _c;
|
||||
item;
|
||||
}
|
||||
finally {
|
||||
_a = true;
|
||||
}
|
||||
const item = _c;
|
||||
item;
|
||||
}
|
||||
}
|
||||
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
||||
|
||||
@@ -93,16 +93,11 @@ System.register([], function (exports_1, context_1) {
|
||||
// for-await-of
|
||||
arr = [Promise.resolve()];
|
||||
try {
|
||||
for (var _a = true, arr_1 = __asyncValues(arr), arr_1_1; arr_1_1 = await arr_1.next(), _a = arr_1_1.done, !_a;) {
|
||||
for (var _a = true, arr_1 = __asyncValues(arr), arr_1_1; arr_1_1 = await arr_1.next(), _a = arr_1_1.done, !_a; _a = true) {
|
||||
_c = arr_1_1.value;
|
||||
_a = false;
|
||||
try {
|
||||
const item = _c;
|
||||
item;
|
||||
}
|
||||
finally {
|
||||
_a = true;
|
||||
}
|
||||
const item = _c;
|
||||
item;
|
||||
}
|
||||
}
|
||||
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
||||
|
||||
Reference in New Issue
Block a user