Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
fix for subscript assignemnt with no args
- Loading branch information
Showing
with
5 additions
and
1 deletion.
-
+3
−0
tests/test_parser.py
-
+2
−1
topaz/parser.py
|
@@ -831,6 +831,9 @@ def test_subscript_assginment(self, space): |
|
|
assert space.parse("x[0] = 5") == ast.Main(ast.Block([ |
|
|
ast.Statement(ast.Assignment(ast.Subscript(ast.Send(ast.Self(1), "x", [], None, 1), [ast.ConstantInt(0)], 1), ast.ConstantInt(5))) |
|
|
])) |
|
|
assert space.parse("x[] = 5") == ast.Main(ast.Block([ |
|
|
ast.Statement(ast.Assignment(ast.Subscript(ast.Send(ast.Self(1), "x", [], None, 1), [], 1), ast.ConstantInt(5))) |
|
|
])) |
|
|
|
|
|
def test_def(self, space): |
|
|
assert space.parse("def f() end") == ast.Main(ast.Block([ |
|
|
|
@@ -951,7 +951,8 @@ def lhs_variable(self, p): |
|
|
|
|
|
@pg.production("lhs : primary_value LITERAL_LBRACKET opt_call_args rbracket") |
|
|
def lhs_subscript(self, p): |
|
|
return BoxAST(ast.Subscript(p[0].getast(), p[2].getcallargs(), p[1].getsourcepos().lineno)) |
|
|
args = p[2].getcallargs() if p[2] is not None else [] |
|
|
return BoxAST(ast.Subscript(p[0].getast(), args, p[1].getsourcepos().lineno)) |
|
|
|
|
|
@pg.production("lhs : primary_value DOT IDENTIFIER") |
|
|
def lhs_dot_identifier(self, p): |
|
|