fix #16469 vm float constants: do not conflate -0.0 and 0.0 (#16470)

* fix #16469 vm float constants: do not conflate -0.0 and 0.0

* fix test for 32bit
This commit is contained in:
Timothee Cour 2020-12-27 05:35:01 -08:00 • committed by GitHub
commit 357729639f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 20 additions and 2 deletions

View file

@ -453,7 +453,12 @@ proc sameConstant*(a, b: PNode): bool =
of nkSym: result = a.sym == b.sym
of nkIdent: result = a.ident.id == b.ident.id
of nkCharLit..nkUInt64Lit: result = a.intVal == b.intVal
of nkFloatLit..nkFloat64Lit: result = a.floatVal == b.floatVal
of nkFloatLit..nkFloat64Lit:
result = cast[uint64](a.floatVal) == cast[uint64](b.floatVal)
# refs bug #16469
# if we wanted to only distinguish 0.0 vs -0.0:
# if a.floatVal == 0.0: result = cast[uint64](a.floatVal) == cast[uint64](b.floatVal)
# else: result = a.floatVal == b.floatVal
of nkStrLit..nkTripleStrLit: result = a.strVal == b.strVal
of nkType, nkNilLit: result = a.typ == b.typ
of nkEmpty: result = true