added SyntaxKind.ModuleDeclaration to list of block scope containers

This commit is contained in:
Vladimir Matveev
2015-02-26 11:58:40 -08:00
parent b183f8dca6
commit 4ff22a0886
3 changed files with 12 additions and 12 deletions
+1 -5
View File
@@ -5086,10 +5086,6 @@ module ts {
return getNarrowedTypeOfSymbol(getExportSymbolOfValueSymbolIfExported(symbol), node);
}
function isNameScopeBoundary(n: Node): boolean {
return isAnyFunction(n) || n.kind === SyntaxKind.ModuleDeclaration || n.kind === SyntaxKind.SourceFile;
}
function checkBlockScopedBindingCapturedInLoop(node: Identifier, symbol: Symbol): void {
if (languageVersion >= ScriptTarget.ES6 || (symbol.flags & SymbolFlags.BlockScopedVariable) === 0) {
return;
@@ -5116,7 +5112,7 @@ module ts {
}
var current: Node = container;
while (current && !isNameScopeBoundary(current)) {
while (current && !nodeStartsNewLexicalEnvironment(current)) {
if (isIterationStatement(current, /*lookInLabeledStatements*/ false)) {
if (inFunction) {
grammarErrorOnFirstToken(current, Diagnostics.Code_in_the_loop_captures_block_scoped_variable_0_in_closure_This_is_natively_supported_in_ECMAScript_6_or_higher, declarationNameToString(node));
+6 -7
View File
@@ -3832,21 +3832,20 @@ module ts {
return current;
}
switch (current.kind) {
case SyntaxKind.SourceFile:
case SyntaxKind.SwitchKeyword:
case SyntaxKind.CatchClause:
case SyntaxKind.ModuleDeclaration:
case SyntaxKind.ForStatement:
case SyntaxKind.ForInStatement:
case SyntaxKind.ForOfStatement:
case SyntaxKind.SwitchKeyword:
return current;
case SyntaxKind.Block:
if (isAnyFunction(current.parent)) {
return current.parent;
}
else {
// function block is not considered block-scope container
// see comment in binder.ts: bind(...), case for SyntaxKind.Block
if (!isAnyFunction(current.parent)) {
return current;
}
case SyntaxKind.SourceFile:
return current;
}
current = current.parent;
+5
View File
@@ -1117,6 +1117,11 @@ module ts {
return createTextChangeRange(createTextSpanFromBounds(oldStartN, oldEndN), /*newLength: */newEndN - oldStartN);
}
// @internal
export function nodeStartsNewLexicalEnvironment(n: Node): boolean {
return isAnyFunction(n) || n.kind === SyntaxKind.ModuleDeclaration || n.kind === SyntaxKind.SourceFile;
}
// @internal
export function nodeIsSynthesized(node: Node): boolean {
return node.pos === -1 && node.end === -1;