Skip to content
Permalink
Browse files

fix for subscript assignemnt with no args

  • Loading branch information
Alex Gaynor
Alex Gaynor committed Apr 2, 2013
1 parent 8733723 commit f6b09d85b5a910036dd57e979e26aa5ca14dd74a
Showing with 5 additions and 1 deletion.
  1. +3 −0 tests/test_parser.py
  2. +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):

0 comments on commit f6b09d8

Please sign in to comment.