mirror of
https://github.com/pocketpy/pocketpy
synced 2025-10-19 19:10:17 +00:00
fix context bug
This commit is contained in:
parent
72e88892e5
commit
93c2608c19
@ -2694,6 +2694,7 @@ static Error* compile_stmt(Compiler* self) {
|
|||||||
vtdelete((Expr*)as_name);
|
vtdelete((Expr*)as_name);
|
||||||
if(!ok) return SyntaxError(self, "invalid syntax");
|
if(!ok) return SyntaxError(self, "invalid syntax");
|
||||||
} else {
|
} else {
|
||||||
|
// discard `__enter__()`'s return value
|
||||||
Ctx__emit_(ctx(), OP_POP_TOP, BC_NOARG, BC_KEEPLINE);
|
Ctx__emit_(ctx(), OP_POP_TOP, BC_NOARG, BC_KEEPLINE);
|
||||||
}
|
}
|
||||||
check(compile_block_body(self, compile_stmt));
|
check(compile_block_body(self, compile_stmt));
|
||||||
|
@ -1020,6 +1020,7 @@ FrameResult VM__run_top_frame(VM* self) {
|
|||||||
goto __ERROR;
|
goto __ERROR;
|
||||||
}
|
}
|
||||||
if(!py_vectorcall(0, 0)) goto __ERROR;
|
if(!py_vectorcall(0, 0)) goto __ERROR;
|
||||||
|
POP();
|
||||||
DISPATCH();
|
DISPATCH();
|
||||||
}
|
}
|
||||||
///////////
|
///////////
|
||||||
|
@ -92,3 +92,14 @@ class fixed(TValue[int]):
|
|||||||
return super().__new__(cls, int(value))
|
return super().__new__(cls, int(value))
|
||||||
|
|
||||||
assert fixed('123').value == 123
|
assert fixed('123').value == 123
|
||||||
|
|
||||||
|
# context bug
|
||||||
|
class Context:
|
||||||
|
def __enter__(self):
|
||||||
|
return 1
|
||||||
|
def __exit__(self, *_):
|
||||||
|
pass
|
||||||
|
|
||||||
|
for _ in range(5):
|
||||||
|
with Context() as x:
|
||||||
|
assert x == 1
|
||||||
|
Loading…
x
Reference in New Issue
Block a user