Merge pull request #13996 from s-hadinger/berry_instance_func

Berry allow instance functions
This commit is contained in:
s-hadinger 2021-12-10 22:35:11 +01:00 committed by GitHub
commit 7465f550d1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 4 deletions

View File

@ -853,8 +853,8 @@ newframe: /* a new call frame */
reg = vm->reg;
bvalue *a = RA();
*a = a_temp;
if (basetype(type) == BE_FUNCTION) {
if (func_isstatic(a)) {
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);

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