mirror of https://github.com/arendst/Tasmota.git
Berry fix static allocation when superclass is a member (#20385)
This commit is contained in:
parent
03aea58a4c
commit
6768ebc2ac
|
@ -1571,15 +1571,11 @@ static void class_stmt(bparser *parser)
|
||||||
begin_block(parser->finfo, &binfo, 0);
|
begin_block(parser->finfo, &binfo, 0);
|
||||||
|
|
||||||
bstring *class_str = parser_newstr(parser, "_class"); /* we always define `_class` local variable */
|
bstring *class_str = parser_newstr(parser, "_class"); /* we always define `_class` local variable */
|
||||||
if (e.type == ETLOCAL) {
|
|
||||||
bexpdesc e1; /* if inline class, we add a second local variable for _class */
|
bexpdesc e1; /* if inline class, we add a second local variable for _class */
|
||||||
init_exp(&e1, ETLOCAL, 0);
|
init_exp(&e1, ETLOCAL, 0);
|
||||||
e1.v.idx = new_localvar(parser, class_str);
|
e1.v.idx = new_localvar(parser, class_str);
|
||||||
be_code_setvar(parser->finfo, &e1, &e, 1);
|
be_code_setvar(parser->finfo, &e1, &e, 1);
|
||||||
} else { /* if global class, we just reuse the newly created class in the register */
|
|
||||||
init_exp(&e, ETLOCAL, 0);
|
|
||||||
e.v.idx = new_localvar(parser, class_str);
|
|
||||||
}
|
|
||||||
begin_varinfo(parser, class_str);
|
begin_varinfo(parser, class_str);
|
||||||
|
|
||||||
class_block(parser, c, &e);
|
class_block(parser, c, &e);
|
||||||
|
|
|
@ -155,3 +155,12 @@ assert(A.a == 1)
|
||||||
assert(A.b == A)
|
assert(A.b == A)
|
||||||
assert(A.c == [1, A])
|
assert(A.c == [1, A])
|
||||||
assert(A.f(1) == A)
|
assert(A.f(1) == A)
|
||||||
|
|
||||||
|
# bug when superclass is a member
|
||||||
|
# the following would break with:
|
||||||
|
#
|
||||||
|
# attribute_error: class 'B' cannot assign to static attribute 'aa'
|
||||||
|
# stack traceback:
|
||||||
|
# stdin:1: in function `main`
|
||||||
|
class B end m = module('m') m.B = B
|
||||||
|
class A : m.B static aa = 1 end
|
||||||
|
|
Loading…
Reference in New Issue