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 blocks taking a single unpacking argument. (e.g. { |(x, y) })
- Loading branch information
Showing
with
19 additions
and
3 deletions.
-
+16
−0
tests/test_parser.py
-
+3
−3
topaz/parser.py
|
@@ -1479,6 +1479,22 @@ def test_block(self, space): |
|
|
)]) |
|
|
), 1)), |
|
|
])) |
|
|
assert space.parse("f { |(x, y)| }") == ast.Main(ast.Block([ |
|
|
ast.Statement(ast.Send(ast.Self(1), "f", [], ast.SendBlock( |
|
|
[ast.Argument("0")], |
|
|
None, |
|
|
None, |
|
|
ast.Block([ |
|
|
ast.Statement(ast.MultiAssignment( |
|
|
ast.MultiAssignable([ |
|
|
ast.Variable("x", -1), |
|
|
ast.Variable("y", -1), |
|
|
]), |
|
|
ast.Variable("0", 1), |
|
|
)) |
|
|
]), |
|
|
), 1)) |
|
|
])) |
|
|
|
|
|
def test_lambda(self, space): |
|
|
assert space.parse("->{}") == ast.Main(ast.Block([ |
|
|
|
@@ -163,7 +163,7 @@ def append_call_arg(self, box_arg, box): |
|
|
|
|
|
def new_send_block(self, lineno, params, body): |
|
|
stmts = body.getastlist() if body is not None else [] |
|
|
args = params.getargs() if params is not None else [] |
|
|
args = params.getargs(include_multi=True) if params is not None else [] |
|
|
splat = params.getsplatarg() if params is not None else None |
|
|
block_arg = params.getblockarg() if params is not None else None |
|
|
|
|
@@ -2933,8 +2933,8 @@ def __init__(self, args, splat_arg, block_arg): |
|
|
self.splat_arg = splat_arg |
|
|
self.block_arg = block_arg |
|
|
|
|
|
def getargs(self): |
|
|
if self.is_multiassignment(): |
|
|
def getargs(self, include_multi=False): |
|
|
if self.is_multiassignment() and not include_multi: |
|
|
return [] |
|
|
else: |
|
|
return self.args |
|
|