Merge pull request #462 from adrian17/lambda_parsing

Change lambda parsing to be closer to Python official grammar. Fixes #427
This commit is contained in:
Adam
2019-02-13 20:44:55 +00:00
committed by GitHub
2 changed files with 7 additions and 1 deletions

View File

@@ -663,7 +663,7 @@ Test: ast::Expression = {
};
LambdaDef: ast::Expression = {
"lambda" <p:TypedArgsList?> ":" <b:Expression> =>
"lambda" <p:TypedArgsList?> ":" <b:Test> =>
ast::Expression::Lambda {
args: p.unwrap_or(Default::default()),
body:Box::new(b)

View File

@@ -5,4 +5,10 @@ assert b == 6
c = 2 + 4 if a > 5 else 'boe'
assert c == 'boe'
d = lambda x, y: x > y
assert d(5, 4)
e = lambda x: 1 if x else 0
assert e(True) == 1
assert e(False) == 0