Berry fixed parser error with upvals in closures (#18902)

This commit is contained in:
s-hadinger 2023-06-18 20:21:08 +02:00 committed by GitHub
parent 4a3b6457ca
commit 1e745807e4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 6 additions and 1 deletions

View File

@ -25,6 +25,7 @@ All notable changes to this project will be documented in this file.
- Fixed HASPmota event when value is non-integer (fixes #18229)
- Matter fix local Occupancy sensor
- Zigbee fixed regression with SetOption101
- Berry fixed parser error with upvals in closures
### Removed

View File

@ -964,9 +964,10 @@ static void suffix_alloc_reg(bparser *parser, bexpdesc *l)
bbool is_suffix = l->type == ETINDEX || l->type == ETMEMBER; /* is suffix */
bbool is_suffix_reg = l->v.ss.tt == ETREG || l->v.ss.tt == ETLOCAL || l->v.ss.tt == ETGLOBAL || l->v.ss.tt == ETNGLOBAL; /* if suffix, does it need a register */
bbool is_global = l->type == ETGLOBAL || l->type == ETNGLOBAL;
bbool is_upval = l->type == ETUPVAL;
/* in the suffix expression, if the object is a temporary
* variable (l->v.ss.tt == ETREG), it needs to be cached. */
if (is_global || (is_suffix && is_suffix_reg)) {
if (is_global || is_upval || (is_suffix && is_suffix_reg)) {
be_code_allocregs(finfo, 1);
}
}

View File

@ -11,3 +11,6 @@ tick()
assert(l[0]() == [1, 100])
assert(l[1]() == [2, 100])
assert(l[2]() == [3, 100])
# the following failed to compile #344
def test() var nv = 1 var f = def() nv += 2*1 print(nv) end end