From fb06b563a49075561deb6b1453cd9f3a2289fc0b Mon Sep 17 00:00:00 2001 From: blueloveTH Date: Mon, 13 Mar 2023 19:28:45 +0800 Subject: [PATCH] fix https://github.com/blueloveTH/pocketpy/issues/37 --- src/compiler.h | 2 +- src/vm.h | 2 +- tests/_bugs.py | 4 ++++ 3 files changed, 6 insertions(+), 2 deletions(-) create mode 100644 tests/_bugs.py diff --git a/src/compiler.h b/src/compiler.h index 394e5cd3..3957def1 100644 --- a/src/compiler.h +++ b/src/compiler.h @@ -395,7 +395,7 @@ private: } func.code = make_sp(parser->src, func.name.str()); this->codes.push(func.code); - co()->_rvalue += 1; EXPR_TUPLE(); co()->_rvalue -= 1; + co()->_rvalue += 1; EXPR(); co()->_rvalue -= 1; emit(OP_RETURN_VALUE); func.code->optimize(vm); this->codes.pop(); diff --git a/src/vm.h b/src/vm.h index 0692f3cd..f0e3f6e9 100644 --- a/src/vm.h +++ b/src/vm.h @@ -450,7 +450,7 @@ template<> bool _py_cast(VM* vm, const PyVar& obj){ return obj == vm->True; } -PyVar py_var(VM* vm, const char* val){ +PyVar py_var(VM* vm, const char val[]){ return VAR(Str(val)); } diff --git a/tests/_bugs.py b/tests/_bugs.py new file mode 100644 index 00000000..d6b53bb9 --- /dev/null +++ b/tests/_bugs.py @@ -0,0 +1,4 @@ +# https://github.com/blueloveTH/pocketpy/issues/37 + +mp = map(lambda x: x**2, [1, 2, 3, 4, 5] ) +assert list(mp) == [1, 4, 9, 16, 25] \ No newline at end of file