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

Don't use float equality for AST comparisons #1238

Open
wants to merge 20 commits into
base: devel
Choose a base branch
from

Conversation

Clyybber
Copy link
Contributor

@Clyybber Clyybber commented Mar 13, 2024

Summary

Float equality lacks the substitution nor reflexivity properties usually expected from an equality operator, so it's not correct to use float equality in AST comparisons. This PR changes it so that they are compared for bit equality.

Details

  • 0.0 and -0.0 are not being considered equal by the compiler anymore (see added tests)
  • trees.exprStructuralEquivalentStrictSym and it's only usage in sem/semfoldnim have been removed

TODO

These could be included in this PR or be sepeate PRs:

  • Remove analysis for floats from sem/guards.nim sem: remove float analysis from sem/guards #1240
  • Ensure all float constants can round-trip as literals in the renderer
  • Ensure that the backend generate float constants bit equal
  • Issue a warning or hint when float equality doesn't match cmpFloatRep

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant