mirror of https://github.com/arendst/Tasmota.git
Berry report bug fix #106
This commit is contained in:
parent
bd87afeabf
commit
ec33c19dbe
|
@ -54,17 +54,22 @@ void be_initupvals(bvm *vm, bclosure *cl)
|
|||
void be_upvals_close(bvm *vm, bvalue *level)
|
||||
{
|
||||
bupval *node = vm->upvalist, *next;
|
||||
while (node && node->value >= level) {
|
||||
bupval **prev = &vm->upvalist;
|
||||
while (node) {
|
||||
next = node->u.next;
|
||||
if (!node->refcnt) {
|
||||
be_free(vm, node, sizeof(bupval));
|
||||
if (node->value >= level) {
|
||||
if (!node->refcnt) {
|
||||
be_free(vm, node, sizeof(bupval));
|
||||
} else {
|
||||
node->u.value = *node->value; /* move value to upvalue slot */
|
||||
node->value = &node->u.value;
|
||||
}
|
||||
*prev = next; /* remove from linked list */
|
||||
} else {
|
||||
node->u.value = *node->value; /* move value to upvalue slot */
|
||||
node->value = &node->u.value;
|
||||
prev = &node->u.next;
|
||||
}
|
||||
node = next;
|
||||
}
|
||||
vm->upvalist = node;
|
||||
}
|
||||
|
||||
void be_release_upvalues(bvm *vm, bclosure *cl)
|
||||
|
|
|
@ -0,0 +1,13 @@
|
|||
#- test for issue #105 -#
|
||||
|
||||
l=[]
|
||||
def tick()
|
||||
var start=100
|
||||
for i : 1..3
|
||||
l.push(def () return [i, start] end)
|
||||
end
|
||||
end
|
||||
tick()
|
||||
assert(l[0]() == [1, 100])
|
||||
assert(l[1]() == [2, 100])
|
||||
assert(l[2]() == [3, 100])
|
Loading…
Reference in New Issue