mirror of
https://github.com/arendst/Tasmota.git
synced 2025-07-26 04:06:34 +00:00
Merge pull request #13996 from s-hadinger/berry_instance_func
Berry allow instance functions
This commit is contained in:
commit
7465f550d1
@ -853,8 +853,8 @@ newframe: /* a new call frame */
|
|||||||
reg = vm->reg;
|
reg = vm->reg;
|
||||||
bvalue *a = RA();
|
bvalue *a = RA();
|
||||||
*a = a_temp;
|
*a = a_temp;
|
||||||
if (basetype(type) == BE_FUNCTION) {
|
if (var_basetype(a) == BE_FUNCTION) {
|
||||||
if (func_isstatic(a)) {
|
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 */
|
/* static method, don't bother with the instance */
|
||||||
a[1] = a_temp;
|
a[1] = a_temp;
|
||||||
var_settype(a, NOT_METHOD);
|
var_settype(a, NOT_METHOD);
|
||||||
|
@ -64,7 +64,7 @@ A.h = def (x, y) return type(x) end
|
|||||||
assert(type(a.g) == 'function')
|
assert(type(a.g) == 'function')
|
||||||
assert(type(a.h) == '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')
|
||||||
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.h(1,2) == [1,2])
|
||||||
assert(A.g(1,2) == [1,2])
|
assert(A.g(1,2) == [1,2])
|
||||||
assert(A.h(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 -#
|
#- test static initializers -#
|
||||||
class A
|
class A
|
||||||
|
Loading…
x
Reference in New Issue
Block a user