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

promote math.isNaN #16627

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions compiler/semtypes.nim
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
# this module does the semantic checking of type declarations
# included from sem.nim

import math
import std/math

const
errStringOrIdentNodeExpected = "string or ident node expected"
Expand Down Expand Up @@ -252,8 +252,11 @@ proc semRangeAux(c: PContext, n: PNode, prev: PType): PType =
else:
result.n.add semConstExpr(c, range[i])

ringabout marked this conversation as resolved.
Show resolved Hide resolved
if (result.n[0].kind in {nkFloatLit..nkFloat64Lit} and classify(result.n[0].floatVal) == fcNan) or
(result.n[1].kind in {nkFloatLit..nkFloat64Lit} and classify(result.n[1].floatVal) == fcNan):
when not declared(isNaN):
template isNaN(a): untyped = classify(a) == fcNan

if (result.n[0].kind in {nkFloatLit..nkFloat64Lit} and isNaN(result.n[0].floatVal)) or
(result.n[1].kind in {nkFloatLit..nkFloat64Lit} and isNaN(result.n[1].floatVal)):
localError(c.config, n.info, "NaN is not a valid start or end for a range")

if weakLeValue(result.n[0], result.n[1]) == impNo:
Expand Down
2 changes: 1 addition & 1 deletion lib/system.nim
Original file line number Diff line number Diff line change
Expand Up @@ -1508,7 +1508,7 @@ const
## Contains an IEEE floating point value of *Not A Number*.
##
## Note that you cannot compare a floating point value to this value
## and expect a reasonable result - use the `classify` procedure
## and expect a reasonable result - use the `isNaN` or `classify` procedure
## in the `math module <math.html>`_ for checking for NaN.


Expand Down