Better way to check arguments compatibility.
All checks were successful
The build was successful.

This commit is contained in:
Rafal Kupiec 2019-04-05 20:07:56 +02:00
parent a06573408e
commit 95fba30f9b
Signed by: belliash
GPG Key ID: 4E829243E0CFE6B4

View File

@ -5003,16 +5003,15 @@ static sxi32 VmByteCodeExec(
if(rc == PH7_ABORT) { if(rc == PH7_ABORT) {
goto Abort; goto Abort;
} }
if((aFormalArg[n].nType & MEMOBJ_MIXED) == 0 && aFormalArg[n].nType > 0 && pObj->iFlags != aFormalArg[n].nType) { ph7_value *pTmp = PH7_ReserveMemObj(&(*pVm));
if(aFormalArg[n].nType == MEMOBJ_REAL && (pObj->iFlags & MEMOBJ_INT)) { pTmp->iFlags = aFormalArg[n].nType;
/* Silently typecast integer value to float */ rc = PH7_MemObjSafeStore(pObj, pTmp);
ProcMemObjCast xCast = PH7_MemObjCastMethod(aFormalArg[n].nType); if(rc != SXRET_OK) {
xCast(pObj); PH7_VmThrowError(&(*pVm), PH7_CTX_ERR,
} else { "Default value for argument %u of '%z()' does not match the data type", n + 1, &pVmFunc->sName);
PH7_VmThrowError(&(*pVm), PH7_CTX_ERR,
"Default value for argument %u of '%z()' does not match the data type", n + 1, &pVmFunc->sName);
}
} }
pObj->iFlags = pTmp->iFlags;
PH7_MemObjRelease(pTmp);
/* Insert argument index */ /* Insert argument index */
sArg.nIdx = pObj->nIdx; sArg.nIdx = pObj->nIdx;
sArg.pUserData = 0; sArg.pUserData = 0;