Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .cspell.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
"bindgen",
"cstring",
"chrono",
"insta",
"peekable",
"lalrpop",
"memmap",
Expand Down
6 changes: 3 additions & 3 deletions compiler/parser/python.lalrpop
Original file line number Diff line number Diff line change
Expand Up @@ -1274,11 +1274,11 @@ ArgumentList: ArgumentList = {
};

FunctionArgument: (Option<(ast::Location, ast::Location, Option<String>)>, ast::Expr) = {
<e:NamedExpressionTest> <c:CompFor?> => {
<location:@L> <e:NamedExpressionTest> <c:CompFor?> <end_location:@R> => {
let expr = match c {
Some(c) => ast::Expr {
location: e.location,
end_location: e.end_location,
location,
end_location: Some(end_location),
custom: (),
node: ast::ExprKind::GeneratorExp {
elt: Box::new(e),
Expand Down
13 changes: 13 additions & 0 deletions compiler/parser/src/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,19 @@ with (0 as a, 1 as b,): pass
}
}

#[test]
fn test_generator_expression_argument() {
let source = r#"' '.join(
sql
for sql in (
"LIMIT %d" % limit if limit else None,
("OFFSET %d" % offset) if offset else None,
)
)"#;
let parse_ast = parse_expression(source, "<test>").unwrap();
insta::assert_debug_snapshot!(parse_ast);
}
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you, I was lazy 🤦


#[test]
fn test_dict_unpacking() {
let parse_ast = parse_expression(r#"{"a": "b", **c, "d": "e"}"#, "<test>").unwrap();
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.