-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Closed
Closed
Copy link
Labels
bugSomething isn't workingSomething isn't workingformatterRelated to the formatterRelated to the formatter
Milestone
Description
The following code is valid python, but crashes handle_parenthesized_comment:
match a:
case A(
# a
b # b
= # c
2 # d
# e
):
passthread 'main' panicked at 'Unexpected token between nodes: `"\n b # b\n = # c\n "`', crates/ruff_python_formatter/src/comments/placement.rs:147:17
The assert in question:
ruff/crates/ruff_python_formatter/src/comments/placement.rs
Lines 138 to 153 in 1044d66
| if tokenizer | |
| .skip_trivia() | |
| .take_while(|token| { | |
| !matches!( | |
| token.kind, | |
| SimpleTokenKind::As | SimpleTokenKind::Def | SimpleTokenKind::Class | |
| ) | |
| }) | |
| .any(|token| { | |
| debug_assert!( | |
| !matches!(token.kind, SimpleTokenKind::Bogus), | |
| "Unexpected token between nodes: `{:?}`", | |
| locator.slice(TextRange::new(comment.end(), following.start())) | |
| ); | |
| token.kind() == SimpleTokenKind::RParen | |
| }) |
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't workingformatterRelated to the formatterRelated to the formatter