Browse Source

Throw an error if it cannot match the overloaded function/method. This fixes #13.

pull/20/head
Rafal Kupiec 3 years ago
parent
commit
9cae9eb905
Signed by: belliash GPG Key ID: 4E829243E0CFE6B4
1 changed files with 5 additions and 5 deletions
  1. +5
    -5
      engine/vm.c

+ 5
- 5
engine/vm.c View File

@ -630,6 +630,9 @@ static int VmOverloadCompare(SyString *pFirst, SyString *pSecond) {
}
return (int)(zFin - zPtr);
}
/* Forward declaration */
static sxi32 VmLocalExec(ph7_vm *pVm, SySet *pByteCode, ph7_value *pResult);
static sxi32 VmErrorFormat(ph7_vm *pVm, sxi32 iErr, const char *zFormat, ...);
/*
* Select the appropriate VM function for the current call context.
* This is the implementation of the powerful 'function overloading' feature
@ -662,8 +665,8 @@ static ph7_vm_func *VmOverload(
pLink = pLink->pNextName;
}
if(i < 1) {
/* No candidates,return the head of the list */
return pList;
/* No candidates, throw an error */
VmErrorFormat(&(*pVm), PH7_CTX_ERR, "Invalid number of arguments passed to function/method '%s'", pList->sName);
}
if(nArg < 1 || i < 2) {
/* Return the only candidate */
@ -715,9 +718,6 @@ static ph7_vm_func *VmOverload(
/* Appropriate function for the current call context */
return apSet[iTarget];
}
/* Forward declaration */
static sxi32 VmLocalExec(ph7_vm *pVm, SySet *pByteCode, ph7_value *pResult);
static sxi32 VmErrorFormat(ph7_vm *pVm, sxi32 iErr, const char *zFormat, ...);
/*
* Mount a compiled class into the freshly created vitual machine so that
* it can be instanciated from the executed PHP script.


Loading…
Cancel
Save