Skip to content

Bug in order of operations (PLC2801) #9572

@RubenVanEldik

Description

@RubenVanEldik

Hi all!

While updating from Ruff 0.1.11 to 0.1.13 I found a small bug in the newly created rule PLC2801.

I had the code:

a = 2
b = -a.__sub__(1)
# b == -1

With the auto linter Ruff fixed this to:

a = 2
b = -a - 1
# b == -3

The order of operations is changed, to fix this Ruff needs to add some parenthesis (b = -(a-1)).

I have no experience with Rust, so I am not able to help, but I wanted to let you know of the issue. Thank you for making Rust! It's an absolutely amazing tool!!

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions