@@ -6885,7 +6885,7 @@ module ts {
68856885 }
68866886 }
68876887
6888- function checkCollisionsWithConstDeclarations ( node : VariableDeclaration ) {
6888+ function checkCollisionWithConstDeclarations ( node : VariableDeclaration ) {
68896889 // Variable declarations are hoisted to the top of their function scope. They can shadow
68906890 // block scoped declarations, which bind tighter. this will not be flagged as duplicate definition
68916891 // by the binder as the declaration scope is different.
@@ -6906,10 +6906,12 @@ module ts {
69066906 // }
69076907 if ( node . initializer && ( node . flags & NodeFlags . BlockScoped ) === 0 ) {
69086908 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+ }
69136915 }
69146916 }
69156917 }
@@ -6938,8 +6940,7 @@ module ts {
69386940 // Use default messages
69396941 checkTypeAssignableTo ( checkAndMarkExpression ( node . initializer ) , type , node , /*chainedMessage*/ undefined , /*terminalMessage*/ undefined ) ;
69406942 }
6941-
6942- checkCollisionsWithConstDeclarations ( node ) ;
6943+ checkCollisionWithConstDeclarations ( node ) ;
69436944 }
69446945
69456946 checkCollisionWithCapturedSuperVariable ( node , node . name ) ;
0 commit comments