@@ -6885,7 +6885,7 @@ module ts {
6885
6885
}
6886
6886
}
6887
6887
6888
- function checkCollisionsWithConstDeclarations ( node : VariableDeclaration ) {
6888
+ function checkCollisionWithConstDeclarations ( node : VariableDeclaration ) {
6889
6889
// Variable declarations are hoisted to the top of their function scope. They can shadow
6890
6890
// block scoped declarations, which bind tighter. this will not be flagged as duplicate definition
6891
6891
// by the binder as the declaration scope is different.
@@ -6906,10 +6906,12 @@ module ts {
6906
6906
// }
6907
6907
if ( node . initializer && ( node . flags & NodeFlags . BlockScoped ) === 0 ) {
6908
6908
var symbol = getSymbolOfNode ( node ) ;
6909
- var localDeclarationSymbol = resolveName ( node , node . name . text , SymbolFlags . Variable , /*nodeNotFoundErrorMessage*/ undefined , /*nameArg*/ undefined ) ;
6910
- if ( localDeclarationSymbol && localDeclarationSymbol !== symbol && localDeclarationSymbol . flags & SymbolFlags . BlockScopedVariable ) {
6911
- if ( getDeclarationFlagsFromSymbol ( localDeclarationSymbol ) & NodeFlags . Const ) {
6912
- error ( node , Diagnostics . Cannot_redeclare_block_scoped_variable_0 , symbolToString ( localDeclarationSymbol ) ) ;
6909
+ if ( symbol . flags & SymbolFlags . FunctionScopedVariable ) {
6910
+ var localDeclarationSymbol = resolveName ( node , node . name . text , SymbolFlags . Variable , /*nodeNotFoundErrorMessage*/ undefined , /*nameArg*/ undefined ) ;
6911
+ if ( localDeclarationSymbol && localDeclarationSymbol !== symbol && localDeclarationSymbol . flags & SymbolFlags . BlockScopedVariable ) {
6912
+ if ( getDeclarationFlagsFromSymbol ( localDeclarationSymbol ) & NodeFlags . Const ) {
6913
+ error ( node , Diagnostics . Cannot_redeclare_block_scoped_variable_0 , symbolToString ( localDeclarationSymbol ) ) ;
6914
+ }
6913
6915
}
6914
6916
}
6915
6917
}
@@ -6938,8 +6940,7 @@ module ts {
6938
6940
// Use default messages
6939
6941
checkTypeAssignableTo ( checkAndMarkExpression ( node . initializer ) , type , node , /*chainedMessage*/ undefined , /*terminalMessage*/ undefined ) ;
6940
6942
}
6941
-
6942
- checkCollisionsWithConstDeclarations ( node ) ;
6943
+ checkCollisionWithConstDeclarations ( node ) ;
6943
6944
}
6944
6945
6945
6946
checkCollisionWithCapturedSuperVariable ( node , node . name ) ;
0 commit comments