Fix several float range issues

This commit is contained in:
Oscar Nihlgård 2019-08-07 20:34:52 +02:00 • committed by narimiran
commit def6234903
5 changed files with 30 additions and 3 deletions

View file

@ -513,6 +513,12 @@ proc changeType(c: PContext; n: PNode, newType: PType, check: bool) =
if value < firstOrd(c.config, newType) or value > lastOrd(c.config, newType):
localError(c.config, n.info, "cannot convert " & $value &
" to " & typeToString(newType))
of nkFloatLit..nkFloat64Lit:
if check:
echo newType.kind
if not floatRangeCheck(n.floatVal, newType):
localError(c.config, n.info, "cannot convert " & $n.floatVal &
" to " & typeToString(newType))
else: discard
n.typ = newType