mirror of
https://github.com/RustPython/Parser.git
synced 2025-07-19 11:05:45 +00:00
Fix dict spreading in dict literal
This commit is contained in:
parent
ac4d3c076c
commit
581f6e176c
4 changed files with 124 additions and 37 deletions
|
@ -309,4 +309,10 @@ with (0 as a, 1 as b,): pass
|
|||
assert!(parse_program(source, "<test>").is_err());
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_dict_containing_spread() {
|
||||
let parse_ast = parse_expression(r#"{"k": "v", **d}"#, "<test>").unwrap();
|
||||
insta::assert_debug_snapshot!(parse_ast);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,81 @@
|
|||
---
|
||||
source: compiler/parser/src/parser.rs
|
||||
expression: parse_ast
|
||||
---
|
||||
Located {
|
||||
location: Location {
|
||||
row: 1,
|
||||
column: 0,
|
||||
},
|
||||
end_location: Some(
|
||||
Location {
|
||||
row: 1,
|
||||
column: 15,
|
||||
},
|
||||
),
|
||||
custom: (),
|
||||
node: Dict {
|
||||
keys: [
|
||||
Some(
|
||||
Located {
|
||||
location: Location {
|
||||
row: 1,
|
||||
column: 1,
|
||||
},
|
||||
end_location: Some(
|
||||
Location {
|
||||
row: 1,
|
||||
column: 4,
|
||||
},
|
||||
),
|
||||
custom: (),
|
||||
node: Constant {
|
||||
value: Str(
|
||||
"k",
|
||||
),
|
||||
kind: None,
|
||||
},
|
||||
},
|
||||
),
|
||||
None,
|
||||
],
|
||||
values: [
|
||||
Located {
|
||||
location: Location {
|
||||
row: 1,
|
||||
column: 6,
|
||||
},
|
||||
end_location: Some(
|
||||
Location {
|
||||
row: 1,
|
||||
column: 9,
|
||||
},
|
||||
),
|
||||
custom: (),
|
||||
node: Constant {
|
||||
value: Str(
|
||||
"v",
|
||||
),
|
||||
kind: None,
|
||||
},
|
||||
},
|
||||
Located {
|
||||
location: Location {
|
||||
row: 1,
|
||||
column: 13,
|
||||
},
|
||||
end_location: Some(
|
||||
Location {
|
||||
row: 1,
|
||||
column: 14,
|
||||
},
|
||||
),
|
||||
custom: (),
|
||||
node: Name {
|
||||
id: "d",
|
||||
ctx: Load,
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue