mirror of
https://github.com/pocketpy/pocketpy
synced 2025-10-21 12:00:18 +00:00
fix a bug
This commit is contained in:
parent
718edd9b9d
commit
ddb20d2f91
@ -65,6 +65,8 @@ struct CodeEmitContext{
|
||||
co->blocks[curr_block_i].end = co->codes.size();
|
||||
curr_block_i = co->blocks[curr_block_i].parent;
|
||||
if(curr_block_i < 0) FATAL_ERROR();
|
||||
// add a no op here to make block check work
|
||||
emit(OP_NO_OP, BC_NOARG, BC_KEEPLINE);
|
||||
}
|
||||
|
||||
// clear the expression stack and generate bytecode
|
||||
|
@ -182,6 +182,11 @@ struct Frame {
|
||||
if(_next_ip >= co->codes.size()){
|
||||
while(i>=0) i = _exit_block(i);
|
||||
}else{
|
||||
// BUG!!!
|
||||
// for i in range(4):
|
||||
// _ = 0
|
||||
// # if there is no op here, the block check will fail
|
||||
// while i: --i
|
||||
const Bytecode& next = co->codes[target];
|
||||
while(i>=0 && i!=next.block) i = _exit_block(i);
|
||||
if(i!=next.block) throw std::runtime_error("invalid jump");
|
||||
|
@ -585,7 +585,7 @@ struct PyMat3x3: Mat3x3{
|
||||
PyVec3& other = _CAST(PyVec3&, args[1]);
|
||||
return VAR_T(PyVec3, self.matmul(other));
|
||||
}
|
||||
vm->TypeError("unsupported operand type(s) for @");
|
||||
vm->BinaryOptError("@");
|
||||
return vm->None;
|
||||
};
|
||||
|
||||
|
@ -47,4 +47,10 @@ assert (
|
||||
assert f((
|
||||
g(1),
|
||||
2
|
||||
)) == (1, 2)
|
||||
)) == (1, 2)
|
||||
|
||||
def f():
|
||||
for i in range(4):
|
||||
_ = 0
|
||||
while i: --i
|
||||
f()
|
Loading…
x
Reference in New Issue
Block a user