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

@ -292,6 +292,9 @@ proc fitRemoveHiddenConv(c: PContext, typ: PType, n: PNode): PNode =
result = newFloatNode(nkFloatLit, BiggestFloat r1.intVal)
result.info = n.info
result.typ = typ
if not floatRangeCheck(result.floatVal, typ):
localError(c.config, n.info, "cannot convert " & $result.floatVal &
" to " & typeToString(typ))
else:
changeType(c, r1, typ, check=true)
result = r1