[syntax-errors] Parenthesized keyword argument names after Python 3.8 (#16482)
Summary
--
Unlike the other syntax errors detected so far, parenthesized keyword
arguments are only allowed *before* 3.8. It sounds like they were only
accidentally allowed before that [^1].
As an aside, you get a pretty confusing error from Python for this, so
it's nice that we can catch it:
```pycon
>>> def f(**kwargs): ...
... f((a)=1)
...
File "<python-input-0>", line 2
f((a)=1)
^^^
SyntaxError: expression cannot contain assignment, perhaps you meant "=="?
>>>
```
Test Plan
--
Inline tests.
[^1]: https://github.com/python/cpython/issues/78822
This commit is contained in:
@@ -424,7 +424,7 @@ impl<'src> Parser<'src> {
|
||||
/// are only allowed in Python 3.8 and later: <https://github.com/python/cpython/issues/76298>.
|
||||
pub(crate) fn check_tuple_unpacking(&mut self, expr: &Expr, kind: StarTupleKind) {
|
||||
let kind = UnsupportedSyntaxErrorKind::StarTuple(kind);
|
||||
if self.options.target_version >= kind.minimum_version() {
|
||||
if kind.is_supported(self.options.target_version) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user