Fix several float range issues (supersedes #11905) (#12067)

* Fix several float range issues

* address the comments
This commit is contained in:
Andreas Rumpf 2019-08-27 23:19:41 +02:00 • committed by GitHub
commit eaebbfa785
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 27 additions and 3 deletions

View file

@ -414,9 +414,10 @@ proc isConvertibleToRange(f, a: PType): bool =
of tyUInt16: result = a.kind in {tyUInt8, tyUInt16, tyUInt}
of tyUInt32: result = a.kind in {tyUInt8, tyUInt16, tyUInt32, tyUInt}
else: result = false
elif f.kind in {tyFloat..tyFloat128} and
a.kind in {tyFloat..tyFloat128}:
result = true
elif f.kind in {tyFloat..tyFloat128}:
# `isIntLit` is correct and should be used above as well, see PR:
# https://github.com/nim-lang/Nim/pull/11197
result = isIntLit(a) or a.kind in {tyFloat..tyFloat128}
proc handleFloatRange(f, a: PType): TTypeRelation =
if a.kind == f.kind: