From 3ce098953e98308fb2c126a0476477878e5f4c7e Mon Sep 17 00:00:00 2001 From: CPunch Date: Mon, 11 Sep 2023 22:17:35 -0500 Subject: [PATCH] fix __proto object getter --- src/cbaselib.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/cbaselib.c b/src/cbaselib.c index aed3239..df2d12c 100644 --- a/src/cbaselib.c +++ b/src/cbaselib.c @@ -168,8 +168,17 @@ int cosmoB_ogetProto(CState *state, int nargs, CValue *args) if (nargs != 1) cosmoV_error(state, "Expected 1 argument, got %d!", nargs); - cosmoV_pushRef(state, (CObj *)cosmoV_readObject(args[0])->_obj.proto); // just return the proto + if (!IS_REF(args[0])) { + cosmoV_typeError(state, "__getter.__proto", "", "%s", cosmoV_typeStr(args[0])); + } + CObj *proto = (CObj *)cosmoV_readRef(args[0])->proto; + if (proto == NULL) { + cosmoV_pushNil(state); + return 1; + } + + cosmoV_pushRef(state, proto); // just return the proto return 1; // 1 result }