Version: rustpython-parser 0.4.0
CPython: 3.12.12 (also reproduced on 3.10.15)
Summary
rustpython-parser rejects call expressions with repeated keyword names that CPython’s ast.parse() accepts.
Minimal repro
import ast
from rustpython_parser import ... # or equivalent Rust:
# ModModule::parse("func(_=1, _=2)", "<test>")
ast.parse("func(_=1, _=2)") # OK
rustpython_parser::ast::ModModule::parse("func(_=1, _=2)", "<test>")
// Err: keyword argument repeated: _ at byte offset 10
Expected
Parser output matches CPython ast.parse():
Call(
func=Name(id='func'),
keywords=[
keyword(arg='', value=Constant(1)),
keyword(arg='', value=Constant(2)),
],
)
Actual
Parse fails with DuplicateKeywordArgumentError / keyword argument repeated: _.
Notes
Affects any repeated keyword name, not only _ (e.g. func(x=1, x=2)).
Positional duplicates are unaffected (func(_, _) parses fine).
CPython compile() also rejects duplicate keywords; ast.parse() does not. As a parser library, rustpython-parser currently follows compile() validation in parser/src/function.rs::parse_args, not ast.parse() behavior.
Suggested fix
Drop duplicate-keyword rejection from call parsing (or gate it behind a stricter mode), so parsed AST matches ast.parse().
Version: rustpython-parser 0.4.0
CPython: 3.12.12 (also reproduced on 3.10.15)
Summary
rustpython-parser rejects call expressions with repeated keyword names that CPython’s ast.parse() accepts.
Minimal repro
Expected
Parser output matches CPython ast.parse():
Call(
func=Name(id='func'),
keywords=[
keyword(arg='', value=Constant(1)),
keyword(arg='', value=Constant(2)),
],
)
Actual
Parse fails with DuplicateKeywordArgumentError / keyword argument repeated: _.
Notes
Affects any repeated keyword name, not only _ (e.g. func(x=1, x=2)).
Positional duplicates are unaffected (func(_, _) parses fine).
CPython compile() also rejects duplicate keywords; ast.parse() does not. As a parser library, rustpython-parser currently follows compile() validation in parser/src/function.rs::parse_args, not ast.parse() behavior.
Suggested fix
Drop duplicate-keyword rejection from call parsing (or gate it behind a stricter mode), so parsed AST matches ast.parse().