mirror of
https://github.com/DarkPlacesEngine/gmqcc.git
synced 2025-03-22 10:41:43 +00:00
implement correct behaviour for shadows locals
This commit is contained in:
parent
ee3aaa58b3
commit
78d04a8352
1 changed files with 3 additions and 2 deletions
5
parser.c
5
parser.c
|
@ -1842,20 +1842,20 @@ static bool parser_variable(parser_t *parser, ast_block *localblock)
|
|||
{
|
||||
if (olddecl)
|
||||
{
|
||||
ast_value_delete(var);
|
||||
if (isparam &&
|
||||
parsewarning(parser, WARN_LOCAL_SHADOWS,
|
||||
"a parameter is shadowing local `%s`", parser_tokval(parser)))
|
||||
{
|
||||
ast_value_delete(var);
|
||||
return false;
|
||||
}
|
||||
else if (!isparam)
|
||||
{
|
||||
ast_value_delete(var);
|
||||
parseerror(parser, "local `%s` already declared here: %s:%i",
|
||||
parser_tokval(parser), ast_ctx(olddecl).file, (int)ast_ctx(olddecl).line);
|
||||
return false;
|
||||
}
|
||||
goto nextvar;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2010,6 +2010,7 @@ static bool parser_variable(parser_t *parser, ast_block *localblock)
|
|||
}
|
||||
}
|
||||
|
||||
nextvar:
|
||||
if (!parser_next(parser)) {
|
||||
ast_value_delete(var);
|
||||
return false;
|
||||
|
|
Loading…
Reference in a new issue