Better way to check arguments compatibility.
The build was successful. Details

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
1 changed files with 8 additions and 9 deletions

View File

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