Browse Source

Another fixes to OOP-related error reporting.

release/v0.1
Rafal Kupiec 1 year ago
parent
commit
53199cac4e
Signed by: belliash GPG Key ID: 4E829243E0CFE6B4
3 changed files with 4 additions and 4 deletions
  1. +1
    -1
      engine/compiler.c
  2. +1
    -1
      engine/oop.c
  3. +2
    -2
      engine/vm.c

+ 1
- 1
engine/compiler.c View File

@ -3458,7 +3458,7 @@ static sxi32 PH7_GenStateCompileClassMethod(
/* Only method signature is allowed */
if(pGen->pIn < pGen->pEnd && (pGen->pIn->nType & PH7_TK_SEMI /* ';'*/) == 0) {
PH7_GenCompileError(pGen, E_ERROR, pGen->pIn->nLine,
"Interface method '%z::%z()' cannot contain body", &pClass->sName, pName);
"Interface or virtual method '%z::%z()' cannot contain body", &pClass->sName, pName);
}
}
/* Store method return data type */

+ 1
- 1
engine/oop.c View File

@ -282,7 +282,7 @@ PH7_PRIVATE sxi32 PH7_ClassInherit(ph7_vm *pVm, ph7_class *pSub, ph7_class *pBas
} else {
if(pMeth->iFlags & PH7_CLASS_ATTR_VIRTUAL) {
/* Virtual method must be defined in the child class */
PH7_VmThrowError(&(*pVm), PH7_CTX_ERR, "Virtual method '%z:%z()' must be defined inside child class '%z'", &pBase->sName, pName, &pSub->sName);
PH7_VmThrowError(&(*pVm), PH7_CTX_ERR, "Virtual method '%z::%z()' must be defined inside child class '%z'", &pBase->sName, pName, &pSub->sName);
}
}
/* Install the method */

+ 2
- 2
engine/vm.c View File

@ -4331,7 +4331,7 @@ static sxi32 VmByteCodeExec(
}
PH7_MemObjRelease(pTos);
} else if((pMeth->iFlags & PH7_CLASS_ATTR_STATIC) == 0 && ((pClass->iFlags & PH7_CLASS_FINAL) == 0 || (pClass->iFlags & PH7_CLASS_VIRTUAL) == 0)) {
PH7_VmThrowError(&(*pVm), PH7_CTX_ERR, "Attempt to call statically a non-static method '%z::%z()'",
PH7_VmThrowError(&(*pVm), PH7_CTX_ERR, "An object reference is required for the non-static method '%z::%z()'",
&pClass->sName, &sName);
} else if(!VmClassMemberAccess(&(*pVm), pClass, pMeth->iProtection)) {
PH7_VmThrowError(&(*pVm), PH7_CTX_ERR, "Method '%z::%z()' is inaccessible due to its protection level",
@ -4364,7 +4364,7 @@ static sxi32 VmByteCodeExec(
if(pAttr) {
if((pAttr->iFlags & (PH7_CLASS_ATTR_STATIC | PH7_CLASS_ATTR_CONSTANT)) == 0) {
/* Access to a non static attribute */
PH7_VmThrowError(&(*pVm), PH7_CTX_ERR, "Access to a non-static class attribute '%z::$%z'",
PH7_VmThrowError(&(*pVm), PH7_CTX_ERR, "An object reference is required for the non-static attribute '%z::$%z'",
&pClass->sName, &pAttr->sName
);
} else {

Loading…
Cancel
Save