do not treat property names in binding elements as block scoped variables

This commit is contained in:
Vladimir Matveev
2015-02-26 16:13:52 -08:00
parent 4ff22a0886
commit 16378e3c1c

View File

@@ -5091,13 +5091,20 @@ module ts {
return;
}
// - check if binding is used in some function
// - check if binding is used in some function
// (stop the walk when reaching container of binding declaration)
// - if first check succeeded - check if variable is declared inside the loop
// var decl -> var decl list -> parent
var container = (<VariableDeclaration>symbol.valueDeclaration).parent.parent;
// nesting structure:
// (variable declaration or binding element) -> variable declaration list -> container
var container: Node = symbol.valueDeclaration;
while (container.kind !== SyntaxKind.VariableDeclarationList) {
container = container.parent;
}
// get the parent of variable declaration list
container = container.parent;
if (container.kind === SyntaxKind.VariableStatement) {
// if parent is variable statement - get its parent
container = container.parent;
}
@@ -10722,6 +10729,12 @@ module ts {
return undefined;
}
// ignore property names in object binding patterns
if (n.parent.kind === SyntaxKind.BindingElement &&
(<BindingElement>n.parent).propertyName === n) {
return undefined;
}
// for names in variable declarations and binding elements try to short circuit and fetch symbol from the node
var declarationSymbol: Symbol =
(n.parent.kind === SyntaxKind.VariableDeclaration && (<VariableDeclaration>n.parent).name === n) ||