From 2a6b59a3ba448d8da0086eb7a16c9b471349f630 Mon Sep 17 00:00:00 2001 From: Vladimir Matveev Date: Tue, 3 Mar 2015 23:46:51 -0800 Subject: [PATCH] addressed PR feedback --- src/compiler/emitter.ts | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/compiler/emitter.ts b/src/compiler/emitter.ts index 054ecb1fc77..b1dcbfbcd95 100644 --- a/src/compiler/emitter.ts +++ b/src/compiler/emitter.ts @@ -1693,12 +1693,29 @@ module ts { } function isExistingName(location: Node, name: string) { + // check if resolver is aware of this name (if name was seen during the typecheck) if (!resolver.isUnknownIdentifier(location, name)) { return true; } + + // check if name is present in generated names that were introduced by the emitter if (currentScopeNames && hasProperty(currentScopeNames, name)) { return true; } + + // check generated names in outer scopes + // var x; + // function foo() { + // let x; // 1 + // function bar() { + // { + // let x; // 2 + // } + // console.log(x); // 3 + // } + //} + // here both x(1) and x(2) should be renamed and their names should be different + // so x in (3) will refer to x(1) var frame = lastFrame; while (frame) { if (hasProperty(frame.names, name)) {