Prohibit starred arguments after double-starred arguments

CPython prohibits ‘f(**kwargs, *args)’; we should too.

Signed-off-by: Anders Kaseorg <andersk@mit.edu>
This commit is contained in:
Anders Kaseorg 2022-12-27 01:48:05 -08:00
parent 313fd7d28c
commit 661b210391
2 changed files with 17 additions and 1 deletions

View file

@ -22,6 +22,7 @@ pub enum LexicalErrorType {
TabsAfterSpaces,
DefaultArgumentError,
PositionalArgumentError,
UnpackedArgumentError,
DuplicateKeywordArgumentError,
UnrecognizedToken { tok: char },
FStringError(FStringErrorType),
@ -55,6 +56,12 @@ impl fmt::Display for LexicalErrorType {
LexicalErrorType::PositionalArgumentError => {
write!(f, "positional argument follows keyword argument")
}
LexicalErrorType::UnpackedArgumentError => {
write!(
f,
"iterable argument unpacking follows keyword argument unpacking"
)
}
LexicalErrorType::UnrecognizedToken { tok } => {
write!(f, "Got unexpected token {tok}")
}