mirror of
https://github.com/pocketpy/pocketpy
synced 2025-10-20 11:30:18 +00:00
bug fix
This commit is contained in:
parent
1de9c1f639
commit
8f34024833
@ -42,12 +42,14 @@ namespace pkpy{
|
|||||||
|
|
||||||
int Frame::_exit_block(ValueStack* _s, int i){
|
int Frame::_exit_block(ValueStack* _s, int i){
|
||||||
auto type = co->blocks[i].type;
|
auto type = co->blocks[i].type;
|
||||||
if(type==CodeBlockType::FOR_LOOP){
|
if(type == CodeBlockType::FOR_LOOP){
|
||||||
_s->pop(); // pop the iterator
|
_s->pop(); // pop the iterator
|
||||||
// pop possible stack memory slots
|
// pop possible stack memory slots
|
||||||
if(_s->top().type == kTpStackMemoryIndex){
|
if(_s->top().type == kTpStackMemoryIndex){
|
||||||
int count = _s->top().as<StackMemory>().count;
|
int count = _s->top().as<StackMemory>().count;
|
||||||
_s->_sp -= (count + 2);
|
PK_DEBUG_ASSERT(count < 0);
|
||||||
|
_s->_sp += count;
|
||||||
|
_s->_sp -= 2; // pop header and tail
|
||||||
}
|
}
|
||||||
}else if(type==CodeBlockType::CONTEXT_MANAGER){
|
}else if(type==CodeBlockType::CONTEXT_MANAGER){
|
||||||
_s->pop();
|
_s->pop();
|
||||||
|
@ -1,3 +1,11 @@
|
|||||||
|
# multi loop bug
|
||||||
|
out = []
|
||||||
|
a = [1, 2]
|
||||||
|
for i in a:
|
||||||
|
for j in a:
|
||||||
|
out.append((i, j))
|
||||||
|
assert (out == [(1, 1), (1, 2), (2, 1), (2, 2)]), out
|
||||||
|
|
||||||
# https://github.com/pocketpy/pocketpy/issues/37
|
# https://github.com/pocketpy/pocketpy/issues/37
|
||||||
|
|
||||||
mp = map(lambda x: x**2, [1, 2, 3, 4, 5] )
|
mp = map(lambda x: x**2, [1, 2, 3, 4, 5] )
|
||||||
|
Loading…
x
Reference in New Issue
Block a user