Skip to content

Commit

Permalink
Allow ins_member to distinguish between absent member and nil value (
Browse files Browse the repository at this point in the history
  • Loading branch information
s-hadinger authored Mar 16, 2024
1 parent 960cc0d commit d537226
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/be_api.c
Original file line number Diff line number Diff line change
Expand Up @@ -665,6 +665,7 @@ BERRY_API bbool be_copy(bvm *vm, int index)
}

/* `onlyins` limits the search to instance, and discards module. Makes sure getmethod does not return anything for module. */
/* may return BE_NONE */
static int ins_member(bvm *vm, int index, const char *k, bbool onlyins)
{
int type = BE_NIL;
Expand All @@ -681,12 +682,12 @@ static int ins_member(bvm *vm, int index, const char *k, bbool onlyins)
bmodule *module = var_toobj(o);
type = be_module_attr(vm, module, be_newstr(vm, k), top);
}
return type == BE_NONE ? BE_NIL : type;
return type;
}

BERRY_API bbool be_getmember(bvm *vm, int index, const char *k)
{
return ins_member(vm, index, k, bfalse) != BE_NIL;
return ins_member(vm, index, k, bfalse) != BE_NONE;
}

BERRY_API bbool be_getmethod(bvm *vm, int index, const char *k)
Expand Down

0 comments on commit d537226

Please sign in to comment.