File tree 1 file changed +15
-1
lines changed
1 file changed +15
-1
lines changed Original file line number Diff line number Diff line change @@ -564,7 +564,7 @@ impl<ANS: AreNewlinesSpaces> ExpressionParser<ANS> {
564
564
preceded!( tag!( "**" ) , call!( Self :: test) ) => { |kwargs: Box <_>| Argument :: Kwargs ( * kwargs) }
565
565
| preceded!( char !( '*' ) , call!( Self :: test) ) => { |args: Box <_>| Argument :: Starargs ( * args) }
566
566
| do_parse!(
567
- name: name >>
567
+ name: name >> // According to the grammar, this should be a 'test', but cpython actually refuses it (for good reasons)
568
568
value: preceded!( char !( '=' ) , call!( Self :: test) ) >> (
569
569
Argument :: Keyword ( name. to_string( ) , * value)
570
570
)
@@ -1341,6 +1341,20 @@ mod tests {
1341
1341
) ;
1342
1342
}
1343
1343
1344
+ #[ test]
1345
+ fn test_call_keyword_expr ( ) {
1346
+ // The Grammar technically allows this, but CPython refuses it for good reasons;
1347
+ // let's do the same.
1348
+ let atom_expr = ExpressionParser :: < NewlinesAreNotSpaces > :: atom_expr;
1349
+ assert_parse_eq (
1350
+ atom_expr ( make_strspan ( "foo(bar1 if baz else bar2=baz)" ) ) ,
1351
+ Ok ( (
1352
+ make_strspan ( "(bar1 if baz else bar2=baz)" ) ,
1353
+ Box :: new ( Expression :: Name ( "foo" . to_string ( ) ) ) ,
1354
+ ) ) ,
1355
+ ) ;
1356
+ }
1357
+
1344
1358
#[ test]
1345
1359
fn test_subscript_simple ( ) {
1346
1360
let atom_expr = ExpressionParser :: < NewlinesAreNotSpaces > :: atom_expr;
You can’t perform that action at this time.
0 commit comments