addressed PR feedback

This commit is contained in:
Vladimir Matveev
2015-10-19 14:10:27 -07:00
parent f0ba3f471a
commit c13c8bf316
18 changed files with 671 additions and 155 deletions
+52 -38
View File
@@ -386,49 +386,61 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
}
interface ConvertedLoopState {
// set of labels that occured inside the converted loop
// used to determine if labeled jump can be emitted as is or it should be dispatched to calling code
/*
* set of labels that occured inside the converted loop
* used to determine if labeled jump can be emitted as is or it should be dispatched to calling code
*/
labels?: Map<string>;
// collection of labeled jumps that transfer control outside the converted loop.
// maps store association 'label -> labelMarker' where
// - label - value of label as it apprear in code
// - label marker - return value that should be interpreted by calling code as 'jump to <label>'
/*
* collection of labeled jumps that transfer control outside the converted loop.
* maps store association 'label -> labelMarker' where
* - label - value of label as it apprear in code
* - label marker - return value that should be interpreted by calling code as 'jump to <label>'
*/
labeledNonLocalBreaks?: Map<string>;
labeledNonLocalContinues?: Map<string>;
// set of non-labeled jumps that transfer control outside the converted loop
// used to emit dispatching logic in the caller of converted loop
/*
* set of non-labeled jumps that transfer control outside the converted loop
* used to emit dispatching logic in the caller of converted loop
*/
nonLocalJumps?: Jump;
// set of non-labeled jumps that should be interpreted as local
// i.e. if converted loop contains normal loop or switch statement then inside this loop break should be treated as local jump
/*
* set of non-labeled jumps that should be interpreted as local
* i.e. if converted loop contains normal loop or switch statement then inside this loop break should be treated as local jump
*/
allowedNonLabeledJumps?: Jump;
// alias for 'arguments' object from the calling code stack frame
// i.e.
// for (let x;;) <statement that captures x in closure and uses 'arguments'>
// should be converted to
// var loop = function(x) { <code where 'arguments' is replaced witg 'arguments_1'> }
// var arguments_1 = arguments
// for (var x;;) loop(x);
// otherwise semantics of the code will be different since 'arguments' inside converted loop body
// will refer to function that holds converted loop.
// This value is set on demand.
/*
* alias for 'arguments' object from the calling code stack frame
* i.e.
* for (let x;;) <statement that captures x in closure and uses 'arguments'>
* should be converted to
* var loop = function(x) { <code where 'arguments' is replaced witg 'arguments_1'> }
* var arguments_1 = arguments
* for (var x;;) loop(x);
* otherwise semantics of the code will be different since 'arguments' inside converted loop body
* will refer to function that holds converted loop.
* This value is set on demand.
*/
argumentsName?: string;
// list of non-block scoped variable declarations that appear inside converted loop
// such variable declarations should be moved outside the loop body
// for (let x;;) {
// var y = 1;
// ...
// }
// should be converted to
// var loop = function(x) {
// y = 1;
// ...
// }
// var y;
// for (var x;;) loop(x);
/*
* list of non-block scoped variable declarations that appear inside converted loop
* such variable declarations should be moved outside the loop body
* for (let x;;) {
* var y = 1;
* ...
* }
* should be converted to
* var loop = function(x) {
* y = 1;
* ...
* }
* var y;
* for (var x;;) loop(x);
*/
hoistedLocalVariables?: Identifier[];
}
@@ -3187,7 +3199,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
convertedLoopState = {};
if (convertedOuterLoopState) {
// convertedOuterLoopState !== undefined means that this converted loop is nested in another converted loop
// convertedOuterLoopState !== undefined means that this converted loop is nested in another converted loop.
// if outer converted loop has already accumulated some state - pass it through
if (convertedOuterLoopState.argumentsName) {
// outer loop has already used 'arguments' so we've already have some name to alias it
@@ -3219,8 +3231,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
convertedOuterLoopState.argumentsName = convertedLoopState.argumentsName;
}
else {
// this is top level converted loop and
// create an alias for 'arguments' object
// this is top level converted loop and we need to create an alias for 'arguments' object
write(`var ${convertedLoopState.argumentsName} = arguments;`);
writeLine();
}
@@ -3237,12 +3248,15 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
write("var ");
let seen: Map<string>;
for (const id of convertedLoopState.hoistedLocalVariables) {
// Don't initialize seen unless we have at least one element.
// Emit a comma to separate for all but the first element.
if (!seen) {
seen = {};
}
else {
write(", ");
}
if (!hasProperty(seen, id.text)) {
emit(id);
seen[id.text] = id.text;
@@ -3674,12 +3688,12 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
function emitReturnStatement(node: ReturnStatement) {
if (convertedLoopState) {
convertedLoopState.nonLocalJumps |= Jump.Return;
write(`return { value: `);
write("return { value: ");
if (node.expression) {
emit(node.expression);
}
else {
write("undefined");
write("void 0");
}
write(" };");
return;
@@ -287,7 +287,7 @@ function foo0(x) {
(function () { return x_1 + v; });
(function () { return x_1 + v; });
if (x_1 == 1) {
return { value: undefined };
return { value: void 0 };
}
};
var v;
@@ -304,7 +304,7 @@ function foo00(x) {
(function () { return x_2 + v; });
(function () { return x_2 + v; });
if (x_2 == 1) {
return { value: undefined };
return { value: void 0 };
}
};
var v;
@@ -320,7 +320,7 @@ function foo1(x) {
(function () { return x_3 + v; });
(function () { return x_3 + v; });
if (x_3 == 1) {
return { value: undefined };
return { value: void 0 };
}
};
var v;
@@ -337,7 +337,7 @@ function foo2(x) {
(function () { return x_4 + v; });
(function () { return x_4 + v; });
if (x_4 == 1) {
return { value: undefined };
return { value: void 0 };
}
};
var v;
@@ -353,7 +353,7 @@ function foo3(x) {
(function () { return x_5 + v; });
(function () { return x_5 + v; });
if (x_5 == 1) {
return { value: undefined };
return { value: void 0 };
}
};
var v;
@@ -370,7 +370,7 @@ function foo4(x) {
(function () { return x_6 + v; });
(function () { return x_6 + v; });
if (x_6 == 1) {
return { value: undefined };
return { value: void 0 };
}
};
var v;
@@ -386,7 +386,7 @@ function foo5(x) {
(function () { return x_7 + y + v; });
(function () { return x_7 + y + v; });
if (x_7 == 1) {
return { value: undefined };
return { value: void 0 };
}
};
var v;
@@ -403,7 +403,7 @@ function foo6(x) {
(function () { return x_8 + y + v; });
(function () { return x_8 + y + v; });
if (x_8 == 1) {
return { value: undefined };
return { value: void 0 };
}
};
var v;
@@ -421,7 +421,7 @@ function foo7(x) {
(function () { return x_9 + y + v; });
(function () { return x_9 + y + v; });
if (x_9 == 1) {
return { value: undefined };
return { value: void 0 };
}
};
var v;
@@ -438,7 +438,7 @@ function foo8(x) {
(function () { return x_10 + y + v; });
(function () { return x_10 + y + v; });
if (x_10 == 1) {
return { value: undefined };
return { value: void 0 };
}
};
var v;
@@ -455,7 +455,7 @@ function foo0_c(x) {
(function () { return x_11 + v; });
(function () { return x_11 + v; });
if (x_11 == 1) {
return { value: undefined };
return { value: void 0 };
}
};
var v;
@@ -472,7 +472,7 @@ function foo00_c(x) {
(function () { return x_12 + v; });
(function () { return x_12 + v; });
if (x_12 == 1) {
return { value: undefined };
return { value: void 0 };
}
};
var v;
@@ -488,7 +488,7 @@ function foo1_c(x) {
(function () { return x_13 + v; });
(function () { return x_13 + v; });
if (x_13 == 1) {
return { value: undefined };
return { value: void 0 };
}
};
var v;
@@ -505,7 +505,7 @@ function foo2_c(x) {
(function () { return x_14 + v; });
(function () { return x_14 + v; });
if (x_14 == 1) {
return { value: undefined };
return { value: void 0 };
}
};
var v;
@@ -521,7 +521,7 @@ function foo3_c(x) {
(function () { return x_15 + v; });
(function () { return x_15 + v; });
if (x_15 == 1) {
return { value: undefined };
return { value: void 0 };
}
};
var v;
@@ -538,7 +538,7 @@ function foo4_c(x) {
(function () { return x_16 + v; });
(function () { return x_16 + v; });
if (x_16 == 1) {
return { value: undefined };
return { value: void 0 };
}
};
var v;
@@ -554,7 +554,7 @@ function foo5_c(x) {
(function () { return x_17 + y + v; });
(function () { return x_17 + y + v; });
if (x_17 == 1) {
return { value: undefined };
return { value: void 0 };
}
};
var v;
@@ -571,7 +571,7 @@ function foo6_c(x) {
(function () { return x_18 + y + v; });
(function () { return x_18 + y + v; });
if (x_18 == 1) {
return { value: undefined };
return { value: void 0 };
}
};
var v;
@@ -588,7 +588,7 @@ function foo7_c(x) {
(function () { return x_19 + y + v; });
(function () { return x_19 + y + v; });
if (x_19 == 1) {
return { value: undefined };
return { value: void 0 };
}
};
var v;
@@ -605,7 +605,7 @@ function foo8_c(x) {
(function () { return x_20 + y + v; });
(function () { return x_20 + y + v; });
if (x_20 == 1) {
return { value: undefined };
return { value: void 0 };
}
};
var v;
@@ -33,6 +33,9 @@ function foo() {
if (x == 2) {
return "123"
}
if (x == 3) {
return;
}
}
if (x == 1) {
break;
@@ -51,7 +54,10 @@ function foo() {
}
if (x == 2) {
return "456";
}
}
if (x == 3) {
return;
}
}
}
}
@@ -90,6 +96,9 @@ function foo_c() {
if (x == 2) {
return "123"
}
if (x == 3) {
return;
}
}
if (x == 1) {
break;
@@ -108,7 +117,10 @@ function foo_c() {
}
if (x == 2) {
return "456";
}
}
if (x == 3) {
return;
}
}
}
}
@@ -145,6 +157,9 @@ function foo() {
if (x == 2) {
return { value: "123" };
}
if (x == 3) {
return { value: void 0 };
}
};
ll1: for (var y = 0; y < 1; ++y) {
var state_1 = _loop_2(y);
@@ -177,6 +192,9 @@ function foo() {
if (x == 2) {
return { value: "456" };
}
if (x == 3) {
return { value: void 0 };
}
};
l1: for (var x = 0; x < 1; ++x) {
var state_2 = _loop_1(x);
@@ -221,6 +239,9 @@ function foo_c() {
if (x == 2) {
return { value: "123" };
}
if (x == 3) {
return { value: void 0 };
}
};
ll1: for (var y = 0; y < 1;) {
var state_3 = _loop_4(y);
@@ -253,6 +274,9 @@ function foo_c() {
if (x == 2) {
return { value: "456" };
}
if (x == 3) {
return { value: void 0 };
}
};
l1: for (var x = 0; x < 1;) {
var state_4 = _loop_3(x);
@@ -69,6 +69,11 @@ function foo() {
return "123"
}
if (x == 3) {
>x : Symbol(x, Decl(capturedLetConstInLoop8.ts, 4, 16))
return;
}
}
if (x == 1) {
>x : Symbol(x, Decl(capturedLetConstInLoop8.ts, 4, 16))
@@ -99,109 +104,124 @@ function foo() {
>x : Symbol(x, Decl(capturedLetConstInLoop8.ts, 4, 16))
return "456";
}
}
if (x == 3) {
>x : Symbol(x, Decl(capturedLetConstInLoop8.ts, 4, 16))
return;
}
}
}
}
function foo_c() {
>foo_c : Symbol(foo_c, Decl(capturedLetConstInLoop8.ts, 55, 1))
>foo_c : Symbol(foo_c, Decl(capturedLetConstInLoop8.ts, 61, 1))
l0:
for (const z = 0; z < 1;) {
>z : Symbol(z, Decl(capturedLetConstInLoop8.ts, 59, 14))
>z : Symbol(z, Decl(capturedLetConstInLoop8.ts, 59, 14))
>z : Symbol(z, Decl(capturedLetConstInLoop8.ts, 65, 14))
>z : Symbol(z, Decl(capturedLetConstInLoop8.ts, 65, 14))
l1:
for (const x = 0; x < 1;) {
>x : Symbol(x, Decl(capturedLetConstInLoop8.ts, 61, 18))
>x : Symbol(x, Decl(capturedLetConstInLoop8.ts, 61, 18))
>x : Symbol(x, Decl(capturedLetConstInLoop8.ts, 67, 18))
>x : Symbol(x, Decl(capturedLetConstInLoop8.ts, 67, 18))
ll1:
for (const y = 0; y < 1;) {
>y : Symbol(y, Decl(capturedLetConstInLoop8.ts, 63, 22))
>y : Symbol(y, Decl(capturedLetConstInLoop8.ts, 63, 22))
>y : Symbol(y, Decl(capturedLetConstInLoop8.ts, 69, 22))
>y : Symbol(y, Decl(capturedLetConstInLoop8.ts, 69, 22))
(function() { return x + y });
>x : Symbol(x, Decl(capturedLetConstInLoop8.ts, 61, 18))
>y : Symbol(y, Decl(capturedLetConstInLoop8.ts, 63, 22))
>x : Symbol(x, Decl(capturedLetConstInLoop8.ts, 67, 18))
>y : Symbol(y, Decl(capturedLetConstInLoop8.ts, 69, 22))
(() => x + y);
>x : Symbol(x, Decl(capturedLetConstInLoop8.ts, 61, 18))
>y : Symbol(y, Decl(capturedLetConstInLoop8.ts, 63, 22))
>x : Symbol(x, Decl(capturedLetConstInLoop8.ts, 67, 18))
>y : Symbol(y, Decl(capturedLetConstInLoop8.ts, 69, 22))
if (y == 1) {
>y : Symbol(y, Decl(capturedLetConstInLoop8.ts, 63, 22))
>y : Symbol(y, Decl(capturedLetConstInLoop8.ts, 69, 22))
break;
}
if (y == 1) {
>y : Symbol(y, Decl(capturedLetConstInLoop8.ts, 63, 22))
>y : Symbol(y, Decl(capturedLetConstInLoop8.ts, 69, 22))
break l1;
}
if (y == 1) {
>y : Symbol(y, Decl(capturedLetConstInLoop8.ts, 63, 22))
>y : Symbol(y, Decl(capturedLetConstInLoop8.ts, 69, 22))
break ll1;
}
if (y == 1) {
>y : Symbol(y, Decl(capturedLetConstInLoop8.ts, 63, 22))
>y : Symbol(y, Decl(capturedLetConstInLoop8.ts, 69, 22))
continue l0;
}
if (x == 2) {
>x : Symbol(x, Decl(capturedLetConstInLoop8.ts, 61, 18))
>x : Symbol(x, Decl(capturedLetConstInLoop8.ts, 67, 18))
continue;
}
if (x == 2) {
>x : Symbol(x, Decl(capturedLetConstInLoop8.ts, 61, 18))
>x : Symbol(x, Decl(capturedLetConstInLoop8.ts, 67, 18))
continue l1;
}
if (x == 2) {
>x : Symbol(x, Decl(capturedLetConstInLoop8.ts, 61, 18))
>x : Symbol(x, Decl(capturedLetConstInLoop8.ts, 67, 18))
continue ll1;
}
if (x == 2) {
>x : Symbol(x, Decl(capturedLetConstInLoop8.ts, 61, 18))
>x : Symbol(x, Decl(capturedLetConstInLoop8.ts, 67, 18))
return "123"
}
if (x == 3) {
>x : Symbol(x, Decl(capturedLetConstInLoop8.ts, 67, 18))
return;
}
}
if (x == 1) {
>x : Symbol(x, Decl(capturedLetConstInLoop8.ts, 61, 18))
>x : Symbol(x, Decl(capturedLetConstInLoop8.ts, 67, 18))
break;
}
if (x == 1) {
>x : Symbol(x, Decl(capturedLetConstInLoop8.ts, 61, 18))
>x : Symbol(x, Decl(capturedLetConstInLoop8.ts, 67, 18))
break l1;
}
if (x == 2) {
>x : Symbol(x, Decl(capturedLetConstInLoop8.ts, 61, 18))
>x : Symbol(x, Decl(capturedLetConstInLoop8.ts, 67, 18))
continue;
}
if (x == 2) {
>x : Symbol(x, Decl(capturedLetConstInLoop8.ts, 61, 18))
>x : Symbol(x, Decl(capturedLetConstInLoop8.ts, 67, 18))
continue l1;
}
if (x == 2) {
>x : Symbol(x, Decl(capturedLetConstInLoop8.ts, 61, 18))
>x : Symbol(x, Decl(capturedLetConstInLoop8.ts, 67, 18))
continue l0;
}
if (x == 2) {
>x : Symbol(x, Decl(capturedLetConstInLoop8.ts, 61, 18))
>x : Symbol(x, Decl(capturedLetConstInLoop8.ts, 67, 18))
return "456";
}
}
if (x == 3) {
>x : Symbol(x, Decl(capturedLetConstInLoop8.ts, 67, 18))
return;
}
}
}
}
@@ -115,6 +115,13 @@ function foo() {
return "123"
>"123" : string
}
if (x == 3) {
>x == 3 : boolean
>x : number
>3 : number
return;
}
}
if (x == 1) {
>x == 1 : boolean
@@ -161,7 +168,14 @@ function foo() {
return "456";
>"456" : string
}
}
if (x == 3) {
>x == 3 : boolean
>x : number
>3 : number
return;
}
}
}
}
@@ -276,6 +290,13 @@ function foo_c() {
return "123"
>"123" : string
}
if (x == 3) {
>x == 3 : boolean
>x : number
>3 : number
return;
}
}
if (x == 1) {
>x == 1 : boolean
@@ -322,7 +343,14 @@ function foo_c() {
return "456";
>"456" : string
}
}
if (x == 3) {
>x == 3 : boolean
>x : number
>3 : number
return;
}
}
}
}
@@ -1,5 +1,4 @@
//// [capturedLetConstInLoop8_ES6.ts]
function foo() {
l0:
for (let z = 0; z < 1; ++z) {
@@ -34,6 +33,9 @@ function foo() {
if (x == 2) {
return "123"
}
if (x == 3) {
return;
}
}
if (x == 1) {
break;
@@ -52,7 +54,10 @@ function foo() {
}
if (x == 2) {
return "456";
}
}
if (x == 3) {
return;
}
}
}
}
@@ -91,6 +96,9 @@ function foo_c() {
if (x == 2) {
return "123"
}
if (x == 3) {
return;
}
}
if (x == 1) {
break;
@@ -109,7 +117,10 @@ function foo_c() {
}
if (x == 2) {
return "456";
}
}
if (x == 3) {
return;
}
}
}
}
@@ -146,6 +157,9 @@ function foo() {
if (x == 2) {
return "123";
}
if (x == 3) {
return;
}
}
if (x == 1) {
break;
@@ -165,6 +179,9 @@ function foo() {
if (x == 2) {
return "456";
}
if (x == 3) {
return;
}
}
}
}
@@ -198,6 +215,9 @@ function foo_c() {
if (x == 2) {
return "123";
}
if (x == 3) {
return;
}
}
if (x == 1) {
break;
@@ -217,6 +237,9 @@ function foo_c() {
if (x == 2) {
return "456";
}
if (x == 3) {
return;
}
}
}
}
@@ -1,208 +1,227 @@
=== tests/cases/compiler/capturedLetConstInLoop8_ES6.ts ===
function foo() {
>foo : Symbol(foo, Decl(capturedLetConstInLoop8_ES6.ts, 0, 0))
l0:
for (let z = 0; z < 1; ++z) {
>z : Symbol(z, Decl(capturedLetConstInLoop8_ES6.ts, 3, 12))
>z : Symbol(z, Decl(capturedLetConstInLoop8_ES6.ts, 3, 12))
>z : Symbol(z, Decl(capturedLetConstInLoop8_ES6.ts, 3, 12))
>z : Symbol(z, Decl(capturedLetConstInLoop8_ES6.ts, 2, 12))
>z : Symbol(z, Decl(capturedLetConstInLoop8_ES6.ts, 2, 12))
>z : Symbol(z, Decl(capturedLetConstInLoop8_ES6.ts, 2, 12))
l1:
for (let x = 0; x < 1; ++x) {
>x : Symbol(x, Decl(capturedLetConstInLoop8_ES6.ts, 5, 16))
>x : Symbol(x, Decl(capturedLetConstInLoop8_ES6.ts, 5, 16))
>x : Symbol(x, Decl(capturedLetConstInLoop8_ES6.ts, 5, 16))
>x : Symbol(x, Decl(capturedLetConstInLoop8_ES6.ts, 4, 16))
>x : Symbol(x, Decl(capturedLetConstInLoop8_ES6.ts, 4, 16))
>x : Symbol(x, Decl(capturedLetConstInLoop8_ES6.ts, 4, 16))
ll1:
for (let y = 0; y < 1; ++y) {
>y : Symbol(y, Decl(capturedLetConstInLoop8_ES6.ts, 7, 20))
>y : Symbol(y, Decl(capturedLetConstInLoop8_ES6.ts, 7, 20))
>y : Symbol(y, Decl(capturedLetConstInLoop8_ES6.ts, 7, 20))
>y : Symbol(y, Decl(capturedLetConstInLoop8_ES6.ts, 6, 20))
>y : Symbol(y, Decl(capturedLetConstInLoop8_ES6.ts, 6, 20))
>y : Symbol(y, Decl(capturedLetConstInLoop8_ES6.ts, 6, 20))
(function() { return x + y });
>x : Symbol(x, Decl(capturedLetConstInLoop8_ES6.ts, 5, 16))
>y : Symbol(y, Decl(capturedLetConstInLoop8_ES6.ts, 7, 20))
>x : Symbol(x, Decl(capturedLetConstInLoop8_ES6.ts, 4, 16))
>y : Symbol(y, Decl(capturedLetConstInLoop8_ES6.ts, 6, 20))
(() => x + y);
>x : Symbol(x, Decl(capturedLetConstInLoop8_ES6.ts, 5, 16))
>y : Symbol(y, Decl(capturedLetConstInLoop8_ES6.ts, 7, 20))
>x : Symbol(x, Decl(capturedLetConstInLoop8_ES6.ts, 4, 16))
>y : Symbol(y, Decl(capturedLetConstInLoop8_ES6.ts, 6, 20))
if (y == 1) {
>y : Symbol(y, Decl(capturedLetConstInLoop8_ES6.ts, 7, 20))
>y : Symbol(y, Decl(capturedLetConstInLoop8_ES6.ts, 6, 20))
break;
}
if (y == 1) {
>y : Symbol(y, Decl(capturedLetConstInLoop8_ES6.ts, 7, 20))
>y : Symbol(y, Decl(capturedLetConstInLoop8_ES6.ts, 6, 20))
break l1;
}
if (y == 1) {
>y : Symbol(y, Decl(capturedLetConstInLoop8_ES6.ts, 7, 20))
>y : Symbol(y, Decl(capturedLetConstInLoop8_ES6.ts, 6, 20))
break ll1;
}
if (y == 1) {
>y : Symbol(y, Decl(capturedLetConstInLoop8_ES6.ts, 7, 20))
>y : Symbol(y, Decl(capturedLetConstInLoop8_ES6.ts, 6, 20))
continue l0;
}
if (x == 2) {
>x : Symbol(x, Decl(capturedLetConstInLoop8_ES6.ts, 5, 16))
>x : Symbol(x, Decl(capturedLetConstInLoop8_ES6.ts, 4, 16))
continue;
}
if (x == 2) {
>x : Symbol(x, Decl(capturedLetConstInLoop8_ES6.ts, 5, 16))
>x : Symbol(x, Decl(capturedLetConstInLoop8_ES6.ts, 4, 16))
continue l1;
}
if (x == 2) {
>x : Symbol(x, Decl(capturedLetConstInLoop8_ES6.ts, 5, 16))
>x : Symbol(x, Decl(capturedLetConstInLoop8_ES6.ts, 4, 16))
continue ll1;
}
if (x == 2) {
>x : Symbol(x, Decl(capturedLetConstInLoop8_ES6.ts, 5, 16))
>x : Symbol(x, Decl(capturedLetConstInLoop8_ES6.ts, 4, 16))
return "123"
}
if (x == 3) {
>x : Symbol(x, Decl(capturedLetConstInLoop8_ES6.ts, 4, 16))
return;
}
}
if (x == 1) {
>x : Symbol(x, Decl(capturedLetConstInLoop8_ES6.ts, 5, 16))
>x : Symbol(x, Decl(capturedLetConstInLoop8_ES6.ts, 4, 16))
break;
}
if (x == 1) {
>x : Symbol(x, Decl(capturedLetConstInLoop8_ES6.ts, 5, 16))
>x : Symbol(x, Decl(capturedLetConstInLoop8_ES6.ts, 4, 16))
break l1;
}
if (x == 2) {
>x : Symbol(x, Decl(capturedLetConstInLoop8_ES6.ts, 5, 16))
>x : Symbol(x, Decl(capturedLetConstInLoop8_ES6.ts, 4, 16))
continue;
}
if (x == 2) {
>x : Symbol(x, Decl(capturedLetConstInLoop8_ES6.ts, 5, 16))
>x : Symbol(x, Decl(capturedLetConstInLoop8_ES6.ts, 4, 16))
continue l1;
}
if (x == 2) {
>x : Symbol(x, Decl(capturedLetConstInLoop8_ES6.ts, 5, 16))
>x : Symbol(x, Decl(capturedLetConstInLoop8_ES6.ts, 4, 16))
continue l0;
}
if (x == 2) {
>x : Symbol(x, Decl(capturedLetConstInLoop8_ES6.ts, 5, 16))
>x : Symbol(x, Decl(capturedLetConstInLoop8_ES6.ts, 4, 16))
return "456";
}
}
if (x == 3) {
>x : Symbol(x, Decl(capturedLetConstInLoop8_ES6.ts, 4, 16))
return;
}
}
}
}
function foo_c() {
>foo_c : Symbol(foo_c, Decl(capturedLetConstInLoop8_ES6.ts, 56, 1))
>foo_c : Symbol(foo_c, Decl(capturedLetConstInLoop8_ES6.ts, 61, 1))
l0:
for (const z = 0; z < 1;) {
>z : Symbol(z, Decl(capturedLetConstInLoop8_ES6.ts, 60, 14))
>z : Symbol(z, Decl(capturedLetConstInLoop8_ES6.ts, 60, 14))
>z : Symbol(z, Decl(capturedLetConstInLoop8_ES6.ts, 65, 14))
>z : Symbol(z, Decl(capturedLetConstInLoop8_ES6.ts, 65, 14))
l1:
for (const x = 0; x < 1;) {
>x : Symbol(x, Decl(capturedLetConstInLoop8_ES6.ts, 62, 18))
>x : Symbol(x, Decl(capturedLetConstInLoop8_ES6.ts, 62, 18))
>x : Symbol(x, Decl(capturedLetConstInLoop8_ES6.ts, 67, 18))
>x : Symbol(x, Decl(capturedLetConstInLoop8_ES6.ts, 67, 18))
ll1:
for (const y = 0; y < 1;) {
>y : Symbol(y, Decl(capturedLetConstInLoop8_ES6.ts, 64, 22))
>y : Symbol(y, Decl(capturedLetConstInLoop8_ES6.ts, 64, 22))
>y : Symbol(y, Decl(capturedLetConstInLoop8_ES6.ts, 69, 22))
>y : Symbol(y, Decl(capturedLetConstInLoop8_ES6.ts, 69, 22))
(function() { return x + y });
>x : Symbol(x, Decl(capturedLetConstInLoop8_ES6.ts, 62, 18))
>y : Symbol(y, Decl(capturedLetConstInLoop8_ES6.ts, 64, 22))
>x : Symbol(x, Decl(capturedLetConstInLoop8_ES6.ts, 67, 18))
>y : Symbol(y, Decl(capturedLetConstInLoop8_ES6.ts, 69, 22))
(() => x + y);
>x : Symbol(x, Decl(capturedLetConstInLoop8_ES6.ts, 62, 18))
>y : Symbol(y, Decl(capturedLetConstInLoop8_ES6.ts, 64, 22))
>x : Symbol(x, Decl(capturedLetConstInLoop8_ES6.ts, 67, 18))
>y : Symbol(y, Decl(capturedLetConstInLoop8_ES6.ts, 69, 22))
if (y == 1) {
>y : Symbol(y, Decl(capturedLetConstInLoop8_ES6.ts, 64, 22))
>y : Symbol(y, Decl(capturedLetConstInLoop8_ES6.ts, 69, 22))
break;
}
if (y == 1) {
>y : Symbol(y, Decl(capturedLetConstInLoop8_ES6.ts, 64, 22))
>y : Symbol(y, Decl(capturedLetConstInLoop8_ES6.ts, 69, 22))
break l1;
}
if (y == 1) {
>y : Symbol(y, Decl(capturedLetConstInLoop8_ES6.ts, 64, 22))
>y : Symbol(y, Decl(capturedLetConstInLoop8_ES6.ts, 69, 22))
break ll1;
}
if (y == 1) {
>y : Symbol(y, Decl(capturedLetConstInLoop8_ES6.ts, 64, 22))
>y : Symbol(y, Decl(capturedLetConstInLoop8_ES6.ts, 69, 22))
continue l0;
}
if (x == 2) {
>x : Symbol(x, Decl(capturedLetConstInLoop8_ES6.ts, 62, 18))
>x : Symbol(x, Decl(capturedLetConstInLoop8_ES6.ts, 67, 18))
continue;
}
if (x == 2) {
>x : Symbol(x, Decl(capturedLetConstInLoop8_ES6.ts, 62, 18))
>x : Symbol(x, Decl(capturedLetConstInLoop8_ES6.ts, 67, 18))
continue l1;
}
if (x == 2) {
>x : Symbol(x, Decl(capturedLetConstInLoop8_ES6.ts, 62, 18))
>x : Symbol(x, Decl(capturedLetConstInLoop8_ES6.ts, 67, 18))
continue ll1;
}
if (x == 2) {
>x : Symbol(x, Decl(capturedLetConstInLoop8_ES6.ts, 62, 18))
>x : Symbol(x, Decl(capturedLetConstInLoop8_ES6.ts, 67, 18))
return "123"
}
if (x == 3) {
>x : Symbol(x, Decl(capturedLetConstInLoop8_ES6.ts, 67, 18))
return;
}
}
if (x == 1) {
>x : Symbol(x, Decl(capturedLetConstInLoop8_ES6.ts, 62, 18))
>x : Symbol(x, Decl(capturedLetConstInLoop8_ES6.ts, 67, 18))
break;
}
if (x == 1) {
>x : Symbol(x, Decl(capturedLetConstInLoop8_ES6.ts, 62, 18))
>x : Symbol(x, Decl(capturedLetConstInLoop8_ES6.ts, 67, 18))
break l1;
}
if (x == 2) {
>x : Symbol(x, Decl(capturedLetConstInLoop8_ES6.ts, 62, 18))
>x : Symbol(x, Decl(capturedLetConstInLoop8_ES6.ts, 67, 18))
continue;
}
if (x == 2) {
>x : Symbol(x, Decl(capturedLetConstInLoop8_ES6.ts, 62, 18))
>x : Symbol(x, Decl(capturedLetConstInLoop8_ES6.ts, 67, 18))
continue l1;
}
if (x == 2) {
>x : Symbol(x, Decl(capturedLetConstInLoop8_ES6.ts, 62, 18))
>x : Symbol(x, Decl(capturedLetConstInLoop8_ES6.ts, 67, 18))
continue l0;
}
if (x == 2) {
>x : Symbol(x, Decl(capturedLetConstInLoop8_ES6.ts, 62, 18))
>x : Symbol(x, Decl(capturedLetConstInLoop8_ES6.ts, 67, 18))
return "456";
}
}
if (x == 3) {
>x : Symbol(x, Decl(capturedLetConstInLoop8_ES6.ts, 67, 18))
return;
}
}
}
}
@@ -1,5 +1,4 @@
=== tests/cases/compiler/capturedLetConstInLoop8_ES6.ts ===
function foo() {
>foo : () => string
@@ -116,6 +115,13 @@ function foo() {
return "123"
>"123" : string
}
if (x == 3) {
>x == 3 : boolean
>x : number
>3 : number
return;
}
}
if (x == 1) {
>x == 1 : boolean
@@ -162,7 +168,14 @@ function foo() {
return "456";
>"456" : string
}
}
if (x == 3) {
>x == 3 : boolean
>x : number
>3 : number
return;
}
}
}
}
@@ -277,6 +290,13 @@ function foo_c() {
return "123"
>"123" : string
}
if (x == 3) {
>x == 3 : boolean
>x : number
>3 : number
return;
}
}
if (x == 1) {
>x == 1 : boolean
@@ -323,7 +343,14 @@ function foo_c() {
return "456";
>"456" : string
}
}
if (x == 3) {
>x == 3 : boolean
>x : number
>3 : number
return;
}
}
}
}
@@ -120,6 +120,23 @@ function foo2() {
}
}
}
}
class C {
constructor(private N: number) { }
foo() {
for (let i = 0; i < 100; i++) {
let f = () => this.N * i;
}
}
}
function foo3 () {
let x = arguments.length;
for (let y of []) {
let z = arguments.length;
(function() { return y + z + arguments.length; });
}
}
//// [capturedLetConstInLoop9.js]
@@ -250,3 +267,30 @@ function foo2() {
}
}
}
var C = (function () {
function C(N) {
this.N = N;
}
C.prototype.foo = function () {
var _this = this;
var _loop_5 = function(i) {
var f = function () { return _this.N * i; };
};
for (var i = 0; i < 100; i++) {
_loop_5(i);
}
};
return C;
})();
function foo3() {
var x = arguments.length;
var _loop_6 = function(y) {
var z = arguments_2.length;
(function () { return y + z + arguments.length; });
};
var arguments_2 = arguments;
for (var _i = 0, _a = []; _i < _a.length; _i++) {
var y = _a[_i];
_loop_6(y);
}
}
@@ -217,3 +217,54 @@ function foo2() {
}
}
}
class C {
>C : Symbol(C, Decl(capturedLetConstInLoop9.ts, 121, 1))
constructor(private N: number) { }
>N : Symbol(N, Decl(capturedLetConstInLoop9.ts, 124, 16))
foo() {
>foo : Symbol(foo, Decl(capturedLetConstInLoop9.ts, 124, 38))
for (let i = 0; i < 100; i++) {
>i : Symbol(i, Decl(capturedLetConstInLoop9.ts, 126, 16))
>i : Symbol(i, Decl(capturedLetConstInLoop9.ts, 126, 16))
>i : Symbol(i, Decl(capturedLetConstInLoop9.ts, 126, 16))
let f = () => this.N * i;
>f : Symbol(f, Decl(capturedLetConstInLoop9.ts, 127, 15))
>this.N : Symbol(N, Decl(capturedLetConstInLoop9.ts, 124, 16))
>this : Symbol(C, Decl(capturedLetConstInLoop9.ts, 121, 1))
>N : Symbol(N, Decl(capturedLetConstInLoop9.ts, 124, 16))
>i : Symbol(i, Decl(capturedLetConstInLoop9.ts, 126, 16))
}
}
}
function foo3 () {
>foo3 : Symbol(foo3, Decl(capturedLetConstInLoop9.ts, 130, 1))
let x = arguments.length;
>x : Symbol(x, Decl(capturedLetConstInLoop9.ts, 133, 7))
>arguments.length : Symbol(IArguments.length, Decl(lib.d.ts, --, --))
>arguments : Symbol(arguments)
>length : Symbol(IArguments.length, Decl(lib.d.ts, --, --))
for (let y of []) {
>y : Symbol(y, Decl(capturedLetConstInLoop9.ts, 134, 12))
let z = arguments.length;
>z : Symbol(z, Decl(capturedLetConstInLoop9.ts, 135, 11))
>arguments.length : Symbol(IArguments.length, Decl(lib.d.ts, --, --))
>arguments : Symbol(arguments)
>length : Symbol(IArguments.length, Decl(lib.d.ts, --, --))
(function() { return y + z + arguments.length; });
>y : Symbol(y, Decl(capturedLetConstInLoop9.ts, 134, 12))
>z : Symbol(z, Decl(capturedLetConstInLoop9.ts, 135, 11))
>arguments.length : Symbol(IArguments.length, Decl(lib.d.ts, --, --))
>arguments : Symbol(arguments)
>length : Symbol(IArguments.length, Decl(lib.d.ts, --, --))
}
}
@@ -295,3 +295,65 @@ function foo2() {
}
}
}
class C {
>C : C
constructor(private N: number) { }
>N : number
foo() {
>foo : () => void
for (let i = 0; i < 100; i++) {
>i : number
>0 : number
>i < 100 : boolean
>i : number
>100 : number
>i++ : number
>i : number
let f = () => this.N * i;
>f : () => number
>() => this.N * i : () => number
>this.N * i : number
>this.N : number
>this : this
>N : number
>i : number
}
}
}
function foo3 () {
>foo3 : () => void
let x = arguments.length;
>x : number
>arguments.length : number
>arguments : IArguments
>length : number
for (let y of []) {
>y : any
>[] : undefined[]
let z = arguments.length;
>z : number
>arguments.length : number
>arguments : IArguments
>length : number
(function() { return y + z + arguments.length; });
>(function() { return y + z + arguments.length; }) : () => any
>function() { return y + z + arguments.length; } : () => any
>y + z + arguments.length : any
>y + z : any
>y : any
>z : number
>arguments.length : number
>arguments : IArguments
>length : number
}
}
@@ -121,6 +121,23 @@ function foo2() {
}
}
}
}
class C {
constructor(private N: number) { }
foo() {
for (let i = 0; i < 100; i++) {
let f = () => this.N * i;
}
}
}
function foo3 () {
let x = arguments.length;
for (let y of []) {
let z = arguments.length;
(function() { return y + z + arguments.length; });
}
}
//// [capturedLetConstInLoop9_ES6.js]
@@ -219,3 +236,20 @@ function foo2() {
}
}
}
class C {
constructor(N) {
this.N = N;
}
foo() {
for (let i = 0; i < 100; i++) {
let f = () => this.N * i;
}
}
}
function foo3() {
let x = arguments.length;
for (let y of []) {
let z = arguments.length;
(function () { return y + z + arguments.length; });
}
}
@@ -218,3 +218,54 @@ function foo2() {
}
}
}
class C {
>C : Symbol(C, Decl(capturedLetConstInLoop9_ES6.ts, 122, 1))
constructor(private N: number) { }
>N : Symbol(N, Decl(capturedLetConstInLoop9_ES6.ts, 125, 16))
foo() {
>foo : Symbol(foo, Decl(capturedLetConstInLoop9_ES6.ts, 125, 38))
for (let i = 0; i < 100; i++) {
>i : Symbol(i, Decl(capturedLetConstInLoop9_ES6.ts, 127, 16))
>i : Symbol(i, Decl(capturedLetConstInLoop9_ES6.ts, 127, 16))
>i : Symbol(i, Decl(capturedLetConstInLoop9_ES6.ts, 127, 16))
let f = () => this.N * i;
>f : Symbol(f, Decl(capturedLetConstInLoop9_ES6.ts, 128, 15))
>this.N : Symbol(N, Decl(capturedLetConstInLoop9_ES6.ts, 125, 16))
>this : Symbol(C, Decl(capturedLetConstInLoop9_ES6.ts, 122, 1))
>N : Symbol(N, Decl(capturedLetConstInLoop9_ES6.ts, 125, 16))
>i : Symbol(i, Decl(capturedLetConstInLoop9_ES6.ts, 127, 16))
}
}
}
function foo3 () {
>foo3 : Symbol(foo3, Decl(capturedLetConstInLoop9_ES6.ts, 131, 1))
let x = arguments.length;
>x : Symbol(x, Decl(capturedLetConstInLoop9_ES6.ts, 134, 7))
>arguments.length : Symbol(IArguments.length, Decl(lib.d.ts, --, --))
>arguments : Symbol(arguments)
>length : Symbol(IArguments.length, Decl(lib.d.ts, --, --))
for (let y of []) {
>y : Symbol(y, Decl(capturedLetConstInLoop9_ES6.ts, 135, 12))
let z = arguments.length;
>z : Symbol(z, Decl(capturedLetConstInLoop9_ES6.ts, 136, 11))
>arguments.length : Symbol(IArguments.length, Decl(lib.d.ts, --, --))
>arguments : Symbol(arguments)
>length : Symbol(IArguments.length, Decl(lib.d.ts, --, --))
(function() { return y + z + arguments.length; });
>y : Symbol(y, Decl(capturedLetConstInLoop9_ES6.ts, 135, 12))
>z : Symbol(z, Decl(capturedLetConstInLoop9_ES6.ts, 136, 11))
>arguments.length : Symbol(IArguments.length, Decl(lib.d.ts, --, --))
>arguments : Symbol(arguments)
>length : Symbol(IArguments.length, Decl(lib.d.ts, --, --))
}
}
@@ -296,3 +296,65 @@ function foo2() {
}
}
}
class C {
>C : C
constructor(private N: number) { }
>N : number
foo() {
>foo : () => void
for (let i = 0; i < 100; i++) {
>i : number
>0 : number
>i < 100 : boolean
>i : number
>100 : number
>i++ : number
>i : number
let f = () => this.N * i;
>f : () => number
>() => this.N * i : () => number
>this.N * i : number
>this.N : number
>this : this
>N : number
>i : number
}
}
}
function foo3 () {
>foo3 : () => void
let x = arguments.length;
>x : number
>arguments.length : number
>arguments : IArguments
>length : number
for (let y of []) {
>y : any
>[] : undefined[]
let z = arguments.length;
>z : number
>arguments.length : number
>arguments : IArguments
>length : number
(function() { return y + z + arguments.length; });
>(function() { return y + z + arguments.length; }) : () => any
>function() { return y + z + arguments.length; } : () => any
>y + z + arguments.length : any
>y + z : any
>y : any
>z : number
>arguments.length : number
>arguments : IArguments
>length : number
}
}
@@ -32,6 +32,9 @@ function foo() {
if (x == 2) {
return "123"
}
if (x == 3) {
return;
}
}
if (x == 1) {
break;
@@ -50,7 +53,10 @@ function foo() {
}
if (x == 2) {
return "456";
}
}
if (x == 3) {
return;
}
}
}
}
@@ -89,6 +95,9 @@ function foo_c() {
if (x == 2) {
return "123"
}
if (x == 3) {
return;
}
}
if (x == 1) {
break;
@@ -107,7 +116,10 @@ function foo_c() {
}
if (x == 2) {
return "456";
}
}
if (x == 3) {
return;
}
}
}
}
@@ -1,5 +1,4 @@
// @target: ES6
function foo() {
l0:
for (let z = 0; z < 1; ++z) {
@@ -34,6 +33,9 @@ function foo() {
if (x == 2) {
return "123"
}
if (x == 3) {
return;
}
}
if (x == 1) {
break;
@@ -52,7 +54,10 @@ function foo() {
}
if (x == 2) {
return "456";
}
}
if (x == 3) {
return;
}
}
}
}
@@ -91,6 +96,9 @@ function foo_c() {
if (x == 2) {
return "123"
}
if (x == 3) {
return;
}
}
if (x == 1) {
break;
@@ -109,7 +117,10 @@ function foo_c() {
}
if (x == 2) {
return "456";
}
}
if (x == 3) {
return;
}
}
}
}
@@ -119,4 +119,21 @@ function foo2() {
}
}
}
}
class C {
constructor(private N: number) { }
foo() {
for (let i = 0; i < 100; i++) {
let f = () => this.N * i;
}
}
}
function foo3 () {
let x = arguments.length;
for (let y of []) {
let z = arguments.length;
(function() { return y + z + arguments.length; });
}
}
@@ -121,4 +121,21 @@ function foo2() {
}
}
}
}
class C {
constructor(private N: number) { }
foo() {
for (let i = 0; i < 100; i++) {
let f = () => this.N * i;
}
}
}
function foo3 () {
let x = arguments.length;
for (let y of []) {
let z = arguments.length;
(function() { return y + z + arguments.length; });
}
}