Merge pull request #11288 from Microsoft/fix11236
Visit VariableDeclaration initializer in converted loop
This commit is contained in:
commit
d1ac8dde0b
5 changed files with 55 additions and 1 deletions
|
@ -1689,7 +1689,7 @@ namespace ts {
|
|||
assignment = flattenVariableDestructuringToExpression(context, decl, hoistVariableDeclaration, /*nameSubstitution*/ undefined, visitor);
|
||||
}
|
||||
else {
|
||||
assignment = createBinary(<Identifier>decl.name, SyntaxKind.EqualsToken, decl.initializer);
|
||||
assignment = createBinary(<Identifier>decl.name, SyntaxKind.EqualsToken, visitNode(decl.initializer, visitor, isExpression));
|
||||
}
|
||||
(assignments || (assignments = [])).push(assignment);
|
||||
}
|
||||
|
|
|
@ -0,0 +1,19 @@
|
|||
//// [transformArrowInBlockScopedLoopVarInitializer.ts]
|
||||
|
||||
// https://github.com/Microsoft/TypeScript/issues/11236
|
||||
while (true)
|
||||
{
|
||||
let local = null;
|
||||
var a = () => local; // <-- Lambda should be converted to function()
|
||||
}
|
||||
|
||||
//// [transformArrowInBlockScopedLoopVarInitializer.js]
|
||||
var _loop_1 = function () {
|
||||
var local = null;
|
||||
a = function () { return local; }; // <-- Lambda should be converted to function()
|
||||
};
|
||||
var a;
|
||||
// https://github.com/Microsoft/TypeScript/issues/11236
|
||||
while (true) {
|
||||
_loop_1();
|
||||
}
|
|
@ -0,0 +1,12 @@
|
|||
=== tests/cases/compiler/transformArrowInBlockScopedLoopVarInitializer.ts ===
|
||||
|
||||
// https://github.com/Microsoft/TypeScript/issues/11236
|
||||
while (true)
|
||||
{
|
||||
let local = null;
|
||||
>local : Symbol(local, Decl(transformArrowInBlockScopedLoopVarInitializer.ts, 4, 7))
|
||||
|
||||
var a = () => local; // <-- Lambda should be converted to function()
|
||||
>a : Symbol(a, Decl(transformArrowInBlockScopedLoopVarInitializer.ts, 5, 7))
|
||||
>local : Symbol(local, Decl(transformArrowInBlockScopedLoopVarInitializer.ts, 4, 7))
|
||||
}
|
|
@ -0,0 +1,15 @@
|
|||
=== tests/cases/compiler/transformArrowInBlockScopedLoopVarInitializer.ts ===
|
||||
|
||||
// https://github.com/Microsoft/TypeScript/issues/11236
|
||||
while (true)
|
||||
>true : true
|
||||
{
|
||||
let local = null;
|
||||
>local : any
|
||||
>null : null
|
||||
|
||||
var a = () => local; // <-- Lambda should be converted to function()
|
||||
>a : () => any
|
||||
>() => local : () => any
|
||||
>local : any
|
||||
}
|
|
@ -0,0 +1,8 @@
|
|||
// @target: es5
|
||||
|
||||
// https://github.com/Microsoft/TypeScript/issues/11236
|
||||
while (true)
|
||||
{
|
||||
let local = null;
|
||||
var a = () => local; // <-- Lambda should be converted to function()
|
||||
}
|
Loading…
Reference in a new issue