Skip to content

Commit

Permalink
fix for subscript assignemnt with no args
Browse files Browse the repository at this point in the history
  • Loading branch information
Alex Gaynor committed Apr 2, 2013
1 parent 8733723 commit f6b09d8
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
3 changes: 3 additions & 0 deletions tests/test_parser.py
Expand Up @@ -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([
Expand Down
3 changes: 2 additions & 1 deletion topaz/parser.py
Expand Up @@ -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):
Expand Down

0 comments on commit f6b09d8

Please sign in to comment.