mirror of
https://github.com/ZDoom/gzdoom.git
synced 2024-11-28 23:02:07 +00:00
restrict new relaxed named arguments to zscript >= 4.13
This commit is contained in:
parent
20cf8befbf
commit
461c2f77b7
1 changed files with 33 additions and 13 deletions
|
@ -9546,6 +9546,8 @@ FxExpression *FxVMFunctionCall::Resolve(FCompileContext& ctx)
|
||||||
|
|
||||||
unsigned implicit = Function->GetImplicitArgs();
|
unsigned implicit = Function->GetImplicitArgs();
|
||||||
|
|
||||||
|
bool relaxed_named_arugments = (ctx.Version >= MakeVersion(4, 13));
|
||||||
|
|
||||||
if (!CheckAccessibility(ctx.Version))
|
if (!CheckAccessibility(ctx.Version))
|
||||||
{
|
{
|
||||||
delete this;
|
delete this;
|
||||||
|
@ -9613,16 +9615,29 @@ FxExpression *FxVMFunctionCall::Resolve(FCompileContext& ctx)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
unsigned j;
|
|
||||||
FName name = static_cast<FxNamedNode *>(ArgList[i])->name;
|
FName name = static_cast<FxNamedNode *>(ArgList[i])->name;
|
||||||
|
if(argnames[index + implicit] != name)
|
||||||
|
{
|
||||||
|
unsigned j;
|
||||||
|
|
||||||
for (j = 0; j < count; j++)
|
for (j = 0; j < count; j++)
|
||||||
{
|
{
|
||||||
if (argnames[j + implicit] == name)
|
if (argnames[j + implicit] == name)
|
||||||
{
|
{
|
||||||
|
if(!relaxed_named_arugments && !(argflags[j + implicit] & VARF_Optional))
|
||||||
|
{
|
||||||
|
ScriptPosition.Message(MSG_ERROR, "Cannot use a named argument here - not all required arguments have been passed.");
|
||||||
|
}
|
||||||
|
else if(!relaxed_named_arugments && j < index)
|
||||||
|
{
|
||||||
|
ScriptPosition.Message(MSG_ERROR, "Named argument %s comes before current position in argument list.", name.GetChars());
|
||||||
|
}
|
||||||
|
|
||||||
// i don't think this needs any further optimization?
|
// i don't think this needs any further optimization?
|
||||||
// O(N^2) complexity technically but N isn't likely to be large,
|
// O(N^2) complexity technically but N isn't likely to be large,
|
||||||
// and the check itself is just an int comparison, so it should be fine
|
// and the check itself is just an int comparison, so it should be fine
|
||||||
index = j;
|
index = j;
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -9634,6 +9649,11 @@ FxExpression *FxVMFunctionCall::Resolve(FCompileContext& ctx)
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else if(!relaxed_named_arugments && !(argflags[index + implicit] & VARF_Optional))
|
||||||
|
{
|
||||||
|
ScriptPosition.Message(MSG_ERROR, "Cannot use a named argument here - not all required arguments have been passed.");
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(index >= count)
|
if(index >= count)
|
||||||
|
|
Loading…
Reference in a new issue