Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid equivalent mutation to unsigned int #240

Open
JonathanFoo0523 opened this issue Jun 19, 2024 · 2 comments · May be fixed by #297 or #309
Open

Avoid equivalent mutation to unsigned int #240

JonathanFoo0523 opened this issue Jun 19, 2024 · 2 comments · May be fixed by #297 or #309
Assignees
Labels
enhancement New feature or request

Comments

@JonathanFoo0523
Copy link
Collaborator

Currently, for unsigned integer a, Dredd allow the mutation:

a != 0

to

a > 0

Both expressions are equivalent. Since Dredd has the type information when traversing the AST, it should be possible to disallow such mutation.

@JonathanFoo0523 JonathanFoo0523 added the enhancement New feature or request label Jul 13, 2024
@afd afd self-assigned this Jul 13, 2024
@afd
Copy link
Member

afd commented Jul 16, 2024

Do not perform the following mutations:

  • a != 0 -> a > 0
  • 0 != a -> 0 < a
  • a op 0 -> a < 0 (subsumed by false)
  • 0 op a -> 0 > a (subsumed by false)
  • a op 0 -> a >= 0 (subsumed by true)
  • 0 op a -> a <= 0 (subsumed by true)

Am I missing anything else @JonathanFoo0523 @JamesLee-Jones?

@JamesLee-Jones
Copy link
Collaborator

Do not perform the following mutations:

  • a != 0 -> a > 0
  • 0 != a -> 0 < a
  • a op 0 -> a < 0 (subsumed by false)
  • 0 op a -> 0 > a (subsumed by false)
  • a op 0 -> a >= 0 (subsumed by true)
  • 0 op a -> a <= 0 (subsumed by true)

Am I missing anything else @JonathanFoo0523 @JamesLee-Jones?

Also:

a == 0 -> a <= 0 (equivalent)
0 == a -> 0 >= a (equivalent)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
3 participants