- ZScript: don't allow multiple assignment syntax with only one element.

This commit is contained in:
Christoph Oelckers 2022-06-16 10:47:11 +02:00
parent 316b9305a2
commit 14fc2a011e

View file

@ -2594,6 +2594,12 @@ FxExpression *FxMultiAssign::Resolve(FCompileContext &ctx)
} }
auto VMRight = static_cast<FxVMFunctionCall *>(Right); auto VMRight = static_cast<FxVMFunctionCall *>(Right);
auto rets = VMRight->GetReturnTypes(); auto rets = VMRight->GetReturnTypes();
if (Base.Size() == 1)
{
Right->ScriptPosition.Message(MSG_ERROR, "Multi-assignment with only one element", VMRight->Function->SymbolName.GetChars());
delete this;
return nullptr;
}
if (rets.Size() < Base.Size()) if (rets.Size() < Base.Size())
{ {
Right->ScriptPosition.Message(MSG_ERROR, "Insufficient returns in function %s", VMRight->Function->SymbolName.GetChars()); Right->ScriptPosition.Message(MSG_ERROR, "Insufficient returns in function %s", VMRight->Function->SymbolName.GetChars());