mirror of
https://github.com/fluencelabs/assemblyscript
synced 2025-04-25 07:02:13 +00:00
Emit diagnostic when redeclaring a local name, fixes #452
This commit is contained in:
parent
4829f3a3e4
commit
c95c0f5fbe
@ -2244,7 +2244,14 @@ export class Compiler extends DiagnosticEmitter {
|
||||
) { // here: not top-level
|
||||
local = flow.addScopedLocal(type, name, false, declaration); // reports
|
||||
} else {
|
||||
local = currentFunction.addLocal(type, name, declaration); // reports
|
||||
if (currentFunction.flow.getScopedLocal(name)) {
|
||||
this.error(
|
||||
DiagnosticCode.Duplicate_identifier_0,
|
||||
declaration.name.range, name
|
||||
);
|
||||
continue;
|
||||
}
|
||||
local = currentFunction.addLocal(type, name, declaration);
|
||||
}
|
||||
if (initExpr) {
|
||||
initializers.push(this.compileAssignmentWithValue(declaration.name, initExpr));
|
||||
|
Loading…
x
Reference in New Issue
Block a user