From b4d723217e67c63addfae44b0592b8bcfc28f22a Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 6 Mar 2015 21:42:42 +0100 Subject: [PATCH] Error on redeclaring a variable with let/const already defined as catch parameter --- src/compiler/checker.ts | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 7220182bfe9..4281d8a5bd3 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -9158,6 +9158,15 @@ module ts { grammarErrorOnFirstToken(catchClause.variableDeclaration.initializer, Diagnostics.Catch_clause_variable_cannot_have_an_initializer); } else { + var identifierName = (catchClause.variableDeclaration.name).text; + var locals = catchClause.block.locals; + if (locals && locals[identifierName]) { + var localSymbol = locals[identifierName] + if (localSymbol && (localSymbol.flags & SymbolFlags.BlockScopedVariable) !== 0) { + grammarErrorOnNode(localSymbol.valueDeclaration, Diagnostics.Cannot_redeclare_identifier_0_in_catch_clause, identifierName); + } + } + // It is a SyntaxError if a TryStatement with a Catch occurs within strict code and the Identifier of the // Catch production is eval or arguments checkGrammarEvalOrArgumentsInStrictMode(node, catchClause.variableDeclaration.name);