-
Notifications
You must be signed in to change notification settings - Fork 39
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
Conversation
instead of sameFloatIgnoreNan
instead of sameFloatIgnoreNan. This does not cause a change in behaviour because only nkNilLit or nkSym nodes reach its only usage in sem/semfold for mEqProc
and remove it from ast/trees as it's now deadcode
instead of sameFloatIgnoreNan and update and add tests to reflect this change in semantics.
and update comments
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A nice fix of a floating-point related edge case, thank you! The review comments I left are very minor and only concern code style and wording of some comments.
For the PR message, could you note down what the affected language features are (e.g., static parameters for generic types and procedures, term-rewriting macros, etc.; can go into the details section), for easier future assessment of what changed?
Co-authored-by: zerbina <[email protected]>
Co-authored-by: zerbina <[email protected]>
/merge Thanks for the review! |
Merge requested by: @Clyybber Contents after the first section break of the PR description has been removed and preserved below:
|
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 compileranymore, this affects:
tests/statictypes/tstatictypes.nim
tests/errmsgs/tforwarddecl_defaultparam.nim
macros.`==`(a, b: NimNode)
, seetests/lang_callable/macros/tmacros_various.nim
tests/lang_experimental/trmacros/trmacros_various2.nim
trees.exprStructuralEquivalentStrictSym
and it's only usage insem/semfoldnim
have been removed