Skip to content

Commit c95c0f5

Browse files
committed
Emit diagnostic when redeclaring a local name, fixes #452
1 parent 4829f3a commit c95c0f5

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

src/compiler.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2244,7 +2244,14 @@ export class Compiler extends DiagnosticEmitter {
22442244
) { // here: not top-level
22452245
local = flow.addScopedLocal(type, name, false, declaration); // reports
22462246
} else {
2247-
local = currentFunction.addLocal(type, name, declaration); // reports
2247+
if (currentFunction.flow.getScopedLocal(name)) {
2248+
this.error(
2249+
DiagnosticCode.Duplicate_identifier_0,
2250+
declaration.name.range, name
2251+
);
2252+
continue;
2253+
}
2254+
local = currentFunction.addLocal(type, name, declaration);
22482255
}
22492256
if (initExpr) {
22502257
initializers.push(this.compileAssignmentWithValue(declaration.name, initExpr));

0 commit comments

Comments
 (0)