mirror of
https://github.com/astral-sh/ruff.git
synced 2025-08-14 23:50:24 +00:00
![]() ## Summary This PR exposes our `is_expression_parenthesized` logic such that we can use it to expand expressions when autofixing to include their parenthesized ranges. This solution has a few drawbacks: (1) we need to compute parenthesized ranges in more places, which also relies on backwards lexing; and (2) we need to make use of this in any relevant fixes. However, I still think it's worth pursuing. On (1), the implementation is very contained, so IMO we can easily swap this out for a more performant solution in the future if needed. On (2), this improves correctness and fixes some bad syntax errors detected by fuzzing, which means it has value even if it's not as robust as an _actual_ `ParenthesizedExpression` node in the AST itself. Closes https://github.com/astral-sh/ruff/issues/4925. ## Test Plan `cargo test` with new cases that previously failed the fuzzer. |
||
---|---|---|
.. | ||
snapshots | ||
identifier.rs | ||
parenthesize.rs | ||
preorder.rs | ||
stmt_if.rs | ||
visitor.rs |