Disallow starred expressions as values of starred expressions#24280
Disallow starred expressions as values of starred expressions#24280dylwil3 merged 3 commits intoastral-sh:mainfrom
Conversation
|
| let parsed_expr = match context.starred_expression_precedence() { | ||
| StarredExpressionPrecedence::Conditional => { | ||
| self.parse_conditional_expression_or_higher_impl(context) | ||
| } | ||
| StarredExpressionPrecedence::Conditional => self | ||
| .parse_conditional_expression_or_higher_impl( | ||
| // test_err starred_starred_expression | ||
| // print(* | ||
| // *[]) | ||
| context.disallow_starred_expressions(), | ||
| ), | ||
| StarredExpressionPrecedence::BitwiseOr => { |
There was a problem hiding this comment.
I initially thought this might not be the correct place but then I realize that this is actually correct given that if we're parsing an expression followed by the * token, then that expression cannot itself be a starred expression unless it's a keyword-variadic argument which is actually a different token (**).
I think we should add this example as well:
print(* *[])For posterity, I thought the issue must be in parse_arguments instead. The lexer emits [..., Star, Star, ...] for the above code and [..., Star, NonLogicalNewline, Star, ...] for the one in the test. So, I thought we'd need to special case this order of two consecutive Star tokens that could contain a NonLogicalNewline token in between and check whether they're actually consecutive or not.
* main: Add a "release-gate" step to the release workflow (#24365) Disallow starred expressions as values of starred expressions (#24280) [`pyupgrade`] Ignore strings with string-only escapes (`UP012`) (#16058) [ty] Improve consistency and quality of diagnostics relating to invalid type forms (#24325) [flake8-type-checking] Clarify import cycle wording for TC001/TC002/TC003 (#24322) [`flake8-errmsg`] Avoid shadowing existing `msg` in fix for `EM101` (#24363) `RUF072`: skip formfeeds on dedent (#24308) Replace unmaintained `unic-ucd-category` crate with `icu_properties` (#24344) [ty] Replace markdown hard line breaks in snapshot tests (#24361) [ty] Move snapshot for code action test with trailing whitespace to external file (#24359)
Part of #19077