mirror of
https://github.com/ZDoom/gzdoom-gles.git
synced 2024-11-28 15:02:39 +00:00
- added an error check for duplicate local variable definitions.
Note that this only applies if both are in the same block. Just like in C++, it is perfectly legal to have the same variable name in two different nested scopes.
This commit is contained in:
parent
b3783a3850
commit
136e976b2a
1 changed files with 13 additions and 0 deletions
|
@ -9975,6 +9975,19 @@ FxExpression *FxLocalVariableDeclaration::Resolve(FCompileContext &ctx)
|
||||||
if (Init) Init = new FxTypeCast(Init, ValueType, false);
|
if (Init) Init = new FxTypeCast(Init, ValueType, false);
|
||||||
SAFE_RESOLVE_OPT(Init, ctx);
|
SAFE_RESOLVE_OPT(Init, ctx);
|
||||||
}
|
}
|
||||||
|
if (Name != NAME_None)
|
||||||
|
{
|
||||||
|
for (auto l : ctx.Block->LocalVars)
|
||||||
|
{
|
||||||
|
if (l->Name == Name)
|
||||||
|
{
|
||||||
|
ScriptPosition.Message(MSG_ERROR, "Local variable %s already defined", Name.GetChars());
|
||||||
|
l->ScriptPosition.Message(MSG_ERROR, "Original definition is here ");
|
||||||
|
delete this;
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
ctx.Block->LocalVars.Push(this);
|
ctx.Block->LocalVars.Push(this);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue