diff --git a/lib/libesp32/Berry/src/be_vm.c b/lib/libesp32/Berry/src/be_vm.c index 67519ee39..26c15a1a3 100644 --- a/lib/libesp32/Berry/src/be_vm.c +++ b/lib/libesp32/Berry/src/be_vm.c @@ -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 { diff --git a/lib/libesp32/Berry/tests/class_const.be b/lib/libesp32/Berry/tests/class_const.be index 7c986bff0..e8f4c1920 100644 --- a/lib/libesp32/Berry/tests/class_const.be +++ b/lib/libesp32/Berry/tests/class_const.be @@ -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