diff options
author | Oscar NihlgÄrd <oscarnihlgard@gmail.com> | 2019-08-31 19:34:08 +0200 |
---|---|---|
committer | Andreas Rumpf <rumpf_a@web.de> | 2019-08-31 19:34:08 +0200 |
commit | 35268c500f2143e757a71846b246a1ecb31c72f8 (patch) | |
tree | b843a8b5c75dc0b5530a1361f1456dcdc05c83de /compiler | |
parent | 6e01be34efd60869c7905b1effcc47880cedfb6d (diff) | |
download | Nim-35268c500f2143e757a71846b246a1ecb31c72f8.tar.gz |
Fix int literals and range interaction (#11197)
* Fix int literals and range interaction * Fix test * remove float range fix; update changelog
Diffstat (limited to 'compiler')
-rw-r--r-- | compiler/sigmatch.nim | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/compiler/sigmatch.nim b/compiler/sigmatch.nim index cec3ecb28..d30703943 100644 --- a/compiler/sigmatch.nim +++ b/compiler/sigmatch.nim @@ -401,18 +401,20 @@ proc handleRange(f, a: PType, min, max: TTypeKind): TTypeRelation = else: result = isNone proc isConvertibleToRange(f, a: PType): bool = - # be less picky for tyRange, as that it is used for array indexing: if f.kind in {tyInt..tyInt64, tyUInt..tyUInt64} and a.kind in {tyInt..tyInt64, tyUInt..tyUInt64}: case f.kind - of tyInt, tyInt64: result = true - of tyInt8: result = a.kind in {tyInt8, tyInt} - of tyInt16: result = a.kind in {tyInt8, tyInt16, tyInt} - of tyInt32: result = a.kind in {tyInt8, tyInt16, tyInt32, tyInt} - of tyUInt, tyUInt64: result = true - of tyUInt8: result = a.kind in {tyUInt8, tyUInt} - of tyUInt16: result = a.kind in {tyUInt8, tyUInt16, tyUInt} - of tyUInt32: result = a.kind in {tyUInt8, tyUInt16, tyUInt32, tyUInt} + of tyInt8: result = isIntLit(a) or a.kind in {tyInt8} + of tyInt16: result = isIntLit(a) or a.kind in {tyInt8, tyInt16} + of tyInt32: result = isIntLit(a) or a.kind in {tyInt8, tyInt16, tyInt32} + # This is wrong, but seems like there's a lot of code that relies on it :( + of tyInt: result = true + of tyInt64: result = isIntLit(a) or a.kind in {tyInt8, tyInt16, tyInt32, tyInt, tyInt64} + of tyUInt8: result = isIntLit(a) or a.kind in {tyUInt8} + of tyUInt16: result = isIntLit(a) or a.kind in {tyUInt8, tyUInt16} + of tyUInt32: result = isIntLit(a) or a.kind in {tyUInt8, tyUInt16, tyUInt32} + of tyUInt: result = isIntLit(a) or a.kind in {tyUInt8, tyUInt16, tyUInt32, tyUInt} + of tyUInt64: result = isIntLit(a) or a.kind in {tyUInt8, tyUInt16, tyUInt32, tyUInt, tyUInt64} else: result = false elif f.kind in {tyFloat..tyFloat128}: # `isIntLit` is correct and should be used above as well, see PR: |