Berry allow instance functions

This commit is contained in:
Stephan Hadinger 2021-12-10 22:23:59 +01:00
parent c26d393112
commit 5242165520
2 changed files with 7 additions and 4 deletions

View File

@ -853,9 +853,9 @@ newframe: /* a new call frame */
reg = vm->reg;
bvalue *a = RA();
*a = a_temp;
if (basetype(type) == BE_FUNCTION) {
if (func_isstatic(a)) {
/* static method, don't bother with the instance */
if (var_basetype(a) == BE_FUNCTION) {
if (func_isstatic(a) || (type == BE_INDEX)) { /* if instance variable then we consider it's non-method */
/* static method, don't bother with the instance */
a[1] = a_temp;
var_settype(a, NOT_METHOD);
} else {

View File

@ -64,7 +64,7 @@ A.h = def (x, y) return type(x) end
assert(type(a.g) == 'function')
assert(type(a.h) == 'function')
assert_attribute_error("a.g(1,2)")
assert(a.g(1) == 'int')
assert(a.h(1) == 'int')
assert(A.h(1) == 'int')
@ -85,6 +85,9 @@ assert(a.g(1,2) == [1,2])
assert(a.h(1,2) == [1,2])
assert(A.g(1,2) == [1,2])
assert(A.h(1,2) == [1,2])
a.a = def (x,y) return [x,y] end
assert(a.a(1,2) == [1,2])
#- test static initializers -#
class A