Skip to content

Commit

Permalink
Add comment about guards.sameTree invalid float equality
Browse files Browse the repository at this point in the history
  • Loading branch information
Clyybber committed Mar 13, 2024
1 parent 7bfa2d2 commit 8a51a12
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion compiler/ast/trees.nim
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ template cmpFloatRep*(a, b: BiggestFloat): bool =
cast[uint64](a) == cast[uint64](b)

template makeTreeEquivalenceProc*(
name, relaxedKindCheck, symCheck, floatCheck, typeCheck, commentCheck) {.dirty.} =
name, relaxedKindCheck,symCheck, floatCheck, typeCheck, commentCheck) {.dirty.} =
## Defines a tree equivalence checking procedure.
## This skeleton is shared between all recursive
## `PNode` equivalence checks in the compiler code base
Expand All @@ -66,6 +66,9 @@ template makeTreeEquivalenceProc*(
of nkIdent: result = a.ident.id == b.ident.id
of nkIntLiterals: result = a.intVal == b.intVal
of nkFloatLiterals: result = floatCheck
# XXX: This should always use cmpFloatRep, see the comment in cmpFloatRep
# but sem/guards.sameTree still incorrectly uses this floatCheck param
# to use float equality instead.
of nkStrLiterals: result = a.strVal == b.strVal
of nkType: result = typeCheck
of nkCommentStmt: result = commentCheck
Expand Down

0 comments on commit 8a51a12

Please sign in to comment.