Typehinting merge #50
10
engine/vm.c
10
engine/vm.c
@ -4983,12 +4983,16 @@ static sxi32 VmByteCodeExec(
|
||||
}
|
||||
}
|
||||
} else if(aFormalArg[n].nType != MEMOBJ_MIXED && ((pArg->iFlags & aFormalArg[n].nType) == 0)) {
|
||||
if(aFormalArg[n].nType == MEMOBJ_REAL && (pArg->iFlags & MEMOBJ_INT)) {
|
||||
/* Silently typecast integer value to float */
|
||||
ProcMemObjCast xCast = PH7_MemObjCastMethod(aFormalArg[n].nType);
|
||||
xCast(pArg);
|
||||
} else {
|
||||
PH7_VmThrowError(&(*pVm), PH7_CTX_ERR,
|
||||
"Argument %u of '%z()' does not match the data type", n + 1, &pVmFunc->sName);
|
||||
}
|
||||
}
|
||||
}
|
||||
if(aFormalArg[n].iFlags & VM_FUNC_ARG_BY_REF) {
|
||||
/* Pass by reference */
|
||||
if(pArg->nIdx == SXU32_HIGH) {
|
||||
@ -5070,9 +5074,15 @@ static sxi32 VmByteCodeExec(
|
||||
goto Abort;
|
||||
}
|
||||
if(aFormalArg[n].nType != MEMOBJ_MIXED && aFormalArg[n].nType > 0 && ((pObj->iFlags & aFormalArg[n].nType) == 0)) {
|
||||
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);
|
||||
}
|
||||
}
|
||||
/* Insert argument index */
|
||||
sArg.nIdx = pObj->nIdx;
|
||||
sArg.pUserData = 0;
|
||||
|
Loading…
Reference in New Issue
Block a user