From 75abe4b138fadd9ce58e05575779a72f119305fe Mon Sep 17 00:00:00 2001 From: "Felix A. Croes" Date: Wed, 16 Nov 2022 20:14:28 +0100 Subject: [PATCH] Let private inheritance fail object type check and cast. But still return -1 for explicit <- calls. --- src/interpret.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/interpret.cpp b/src/interpret.cpp index 27ade316..57e7e0e0 100644 --- a/src/interpret.cpp +++ b/src/interpret.cpp @@ -1252,14 +1252,14 @@ void i_cast(Frame *f, Value *val, unsigned int type, Uint sclass) if (type == T_CLASS) { if (val->type == T_OBJECT) { - if (!i_instanceof(f, val->oindex, sclass)) { + if (i_instanceof(f, val->oindex, sclass) <= 0) { error("Value is not of object type /%s", i_classname(f, sclass)); } return; } else if (val->type == T_LWOBJECT) { elts = d_get_elts(val->u.array); if (elts->type == T_OBJECT) { - if (!i_instanceof(f, elts->oindex, sclass)) { + if (i_instanceof(f, elts->oindex, sclass) <= 0) { error("Value is not of object type /%s", i_classname(f, sclass)); } @@ -2162,14 +2162,14 @@ void i_typecheck(Frame *f, Frame *prog_f, const char *name, const char *ftype, if ((ptype & T_TYPE) == T_CLASS && ptype == T_CLASS && atype == T_OBJECT) { if (f->sp[i].type == T_OBJECT) { - if (!i_instanceof(prog_f, f->sp[i].oindex, sclass)) { + if (i_instanceof(prog_f, f->sp[i].oindex, sclass) <= 0) { error("Bad object argument %d for function %s", nargs - i, name); } } else { elts = d_get_elts(f->sp[i].u.array); if (elts->type == T_OBJECT) { - if (!i_instanceof(prog_f, elts->oindex, sclass)) { + if (i_instanceof(prog_f, elts->oindex, sclass) <= 0) { error("Bad object argument %d for function %s", nargs - i, name); }