Skip to content

Commit 63e4a36

Browse files
committed
added check: named arguments must follow bare star
1 parent 15ab443 commit 63e4a36

1 file changed

Lines changed: 9 additions & 2 deletions

File tree

‎parser/python.lalrpop‎

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -667,7 +667,7 @@ TypedParameter: ast::Arg = {
667667
// TODO: figure out another grammar that makes this inline no longer required.
668668
#[inline]
669669
ParameterListStarArgs<ArgType>: (Option<Box<ast::Arg>>, Vec<ast::Arg>, Vec<ast::Expr>, Option<Box<ast::Arg>>) = {
670-
"*" <va:ArgType?> <kw:("," ParameterDef<ArgType>)*> <kwarg:("," KwargParameter<ArgType>)?> => {
670+
<location:@L> "*" <va:ArgType?> <kw:("," ParameterDef<ArgType>)*> <kwarg:("," KwargParameter<ArgType>)?> =>? {
671671
// Extract keyword arguments:
672672
let mut kwonlyargs = Vec::new();
673673
let mut kw_defaults = Vec::new();
@@ -685,7 +685,14 @@ ParameterListStarArgs<ArgType>: (Option<Box<ast::Arg>>, Vec<ast::Arg>, Vec<ast::
685685
let kwarg = kwarg.map(|n| n.1).flatten();
686686
let va = va.map(Box::new);
687687

688-
(va, kwargs, kw_defaults, kwarg)
688+
if va==None && kwargs.is_empty() && kwarg==None {
689+
Err(LexicalError {
690+
error: LexicalErrorType::OtherError("named arguments must follow bare *".to_string()),
691+
location: location,
692+
})?
693+
}
694+
695+
Ok((va, kwargs, kw_defaults, kwarg))
689696
}
690697
};
691698

0 commit comments

Comments
 (0)