@@ -5091,13 +5091,20 @@ module ts {
5091
5091
return;
5092
5092
}
5093
5093
5094
- // - check if binding is used in some function
5094
+ // - check if binding is used in some function
5095
5095
// (stop the walk when reaching container of binding declaration)
5096
5096
// - if first check succeeded - check if variable is declared inside the loop
5097
5097
5098
- // var decl -> var decl list -> parent
5099
- var container = (<VariableDeclaration>symbol.valueDeclaration).parent.parent;
5098
+ // nesting structure:
5099
+ // (variable declaration or binding element) -> variable declaration list -> container
5100
+ var container: Node = symbol.valueDeclaration;
5101
+ while (container.kind !== SyntaxKind.VariableDeclarationList) {
5102
+ container = container.parent;
5103
+ }
5104
+ // get the parent of variable declaration list
5105
+ container = container.parent;
5100
5106
if (container.kind === SyntaxKind.VariableStatement) {
5107
+ // if parent is variable statement - get its parent
5101
5108
container = container.parent;
5102
5109
}
5103
5110
@@ -10722,6 +10729,12 @@ module ts {
10722
10729
return undefined;
10723
10730
}
10724
10731
10732
+ // ignore property names in object binding patterns
10733
+ if (n.parent.kind === SyntaxKind.BindingElement &&
10734
+ (<BindingElement>n.parent).propertyName === n) {
10735
+ return undefined;
10736
+ }
10737
+
10725
10738
// for names in variable declarations and binding elements try to short circuit and fetch symbol from the node
10726
10739
var declarationSymbol: Symbol =
10727
10740
(n.parent.kind === SyntaxKind.VariableDeclaration && (<VariableDeclaration>n.parent).name === n) ||
0 commit comments