mirror of
https://github.com/pocketpy/pocketpy
synced 2025-10-19 19:10:17 +00:00
fix a bug
This commit is contained in:
parent
2d4cf81356
commit
0109829ad4
@ -242,6 +242,7 @@ FrameResult VM__run_top_frame(VM* self) {
|
||||
DISPATCH();
|
||||
}
|
||||
case OP_LOAD_CLASS_GLOBAL: {
|
||||
assert(self->__curr_class);
|
||||
py_Name name = byte.arg;
|
||||
py_Ref tmp = py_getdict(self->__curr_class, name);
|
||||
if(tmp) {
|
||||
@ -902,6 +903,7 @@ FrameResult VM__run_top_frame(VM* self) {
|
||||
DISPATCH();
|
||||
}
|
||||
case OP_STORE_CLASS_ATTR: {
|
||||
assert(self->__curr_class);
|
||||
py_Name name = byte.arg;
|
||||
if(py_istype(TOP(), tp_function)) {
|
||||
Function* ud = py_touserdata(TOP());
|
||||
@ -912,6 +914,7 @@ FrameResult VM__run_top_frame(VM* self) {
|
||||
DISPATCH();
|
||||
}
|
||||
case OP_ADD_CLASS_ANNOTATION: {
|
||||
assert(self->__curr_class);
|
||||
// [type_hint string]
|
||||
py_Type type = py_totype(self->__curr_class);
|
||||
py_TypeInfo* ti = TypeList__get(&self->types, type);
|
||||
|
@ -137,7 +137,10 @@ void py_clearexc(py_StackRef p0) {
|
||||
vm->last_retval = *py_NIL;
|
||||
vm->curr_exception = *py_NIL;
|
||||
vm->is_curr_exc_handled = false;
|
||||
vm->__curr_class = NULL;
|
||||
|
||||
/* Don't clear this, because StopIteration() may corrupt the class defination */
|
||||
// vm->__curr_class = NULL;
|
||||
|
||||
vm->__curr_function = NULL;
|
||||
if(p0) vm->stack.sp = p0;
|
||||
}
|
||||
|
@ -137,3 +137,9 @@ assert (g == 1), g
|
||||
|
||||
assert list.__new__(list) == []
|
||||
assert a.__new__ == list.__new__
|
||||
|
||||
|
||||
class A:
|
||||
x: list[int] = [i for i in range(1, 4)]
|
||||
|
||||
assert A.x == [1, 2, 3]
|
Loading…
x
Reference in New Issue
Block a user