Fix failed assert when parameter not initialized

fixes #1296
1164-fix
melex750 2020-06-30 10:12:48 -04:00 committed by Mateusz Przybył
parent dece19fbec
commit ebcb124b0e
1 changed files with 6 additions and 10 deletions

View File

@ -64,10 +64,8 @@ CBotDefParam* CBotDefParam::Compile(CBotToken* &p, CBotCStack* pStack)
if (list == nullptr) list = param;
else list->AddNext(param); // added to the list
// CBotClass* pClass = nullptr;//= CBotClass::Find(p);
param->m_typename = p->GetString();
CBotTypResult type = param->m_type = TypeParam(p, pStack);
// if ( type == CBotTypPointer ) type = CBotTypClass; // we must create a new object
if (param->m_type.GetType() > 0)
{
@ -105,7 +103,6 @@ CBotDefParam* CBotDefParam::Compile(CBotToken* &p, CBotCStack* pStack)
if ( type.Eq(CBotTypArrayPointer) ) type.SetType(CBotTypArrayBody);
CBotVar* var = CBotVar::Create(pp->GetString(), type); // creates the variable
// if ( pClass ) var->SetClass(pClass);
var->SetInit(CBotVar::InitType::IS_POINTER); // mark initialized
param->m_nIdent = CBotVar::NextUniqNum();
var->SetUniqNum(param->m_nIdent);
@ -151,13 +148,12 @@ bool CBotDefParam::Execute(CBotVar** ppVars, CBotStack* &pj)
if (useDefault || (ppVars == nullptr || ppVars[i] == nullptr))
{
assert(p->m_expr != nullptr);
useDefault = true;
if (!p->m_expr->Execute(pile)) return false; // interupt here
pVar = pile->GetVar();
useDefault = true; // end of arguments found
if (p->m_expr != nullptr) // has default expression ?
{
if (!p->m_expr->Execute(pile)) return false; // interupt here
pVar = pile->GetVar();
}
}
else
pVar = ppVars[i];