diff --git a/docs/features/differences.md b/docs/features/differences.md index c55c912a..9546ac94 100644 --- a/docs/features/differences.md +++ b/docs/features/differences.md @@ -40,4 +40,5 @@ The easiest way to test a feature is to [try it on your browser](https://pocketp 7. Raw string cannot have boundary quotes in it, even escaped. See [#55](https://github.com/blueloveTH/pocketpy/issues/55). 8. In a starred unpacked assignment, e.g. `a, b, *c = x`, the starred variable can only be presented in the last position. `a, *b, c = x` is not supported. 9. A `Tab` is equivalent to 4 spaces. You can mix `Tab` and spaces in indentation, but it is not recommended. -10. `%`, `&`, `//`, `^` and `|` for `int` behave the same as C, not python. \ No newline at end of file +10. `%`, `&`, `//`, `^` and `|` for `int` behave the same as C, not python. +11. `str.split` and `str.splitlines` will remove all empty entries. diff --git a/src/compiler.cpp b/src/compiler.cpp index 8cef28e2..3b0a30b5 100644 --- a/src/compiler.cpp +++ b/src/compiler.cpp @@ -728,15 +728,8 @@ __EAT_DOTS_END: int n = 0; while(match(TK("="))){ EXPR_TUPLE(); - Expr* _tp = ctx()->s_expr.top().get(); - if(ctx()->is_compiling_class && _tp->is_tuple()){ - SyntaxError("can't use unpack tuple in class definition"); - } n += 1; } - if(ctx()->is_compiling_class && n>1){ - SyntaxError("can't assign to multiple targets in class definition"); - } // stack size is n+1 Expr_ val = ctx()->s_expr.popx(); val->emit_(ctx()); diff --git a/tests/40_class.py b/tests/40_class.py index 0a097dee..bd47351e 100644 --- a/tests/40_class.py +++ b/tests/40_class.py @@ -119,3 +119,13 @@ class A: assert A.x == 2 assert A.y == 1 assert A.z == 3 + +class MyClass: + a = 1,2,3 + b, c = 1, 2 + d = b + c + +assert MyClass.a == (1, 2, 3) +assert MyClass.b == 1 +assert MyClass.c == 2 +assert MyClass.d == 3