diff options
-rw-r--r-- | compiler/sigmatch.nim | 6 | ||||
-rw-r--r-- | tests/arithm/t1.nim | 12 |
2 files changed, 16 insertions, 2 deletions
diff --git a/compiler/sigmatch.nim b/compiler/sigmatch.nim index 591a7c2a2..cf60505dc 100644 --- a/compiler/sigmatch.nim +++ b/compiler/sigmatch.nim @@ -395,9 +395,9 @@ proc handleRange(c: PContext, f, a: PType, min, max: TTypeKind): TTypeRelation = result = isIntConv elif a.kind == tyUInt and nf == c.config.targetSizeUnsignedToKind: result = isIntConv - elif f.kind == tyInt and na in {tyInt8 .. c.config.targetSizeSignedToKind}: + elif f.kind == tyInt and na in {tyInt8 .. pred(c.config.targetSizeSignedToKind)}: result = isIntConv - elif f.kind == tyUInt and na in {tyUInt8 .. c.config.targetSizeUnsignedToKind}: + elif f.kind == tyUInt and na in {tyUInt8 .. pred(c.config.targetSizeUnsignedToKind)}: result = isIntConv elif k >= min and k <= max: result = isConvertible @@ -2116,6 +2116,8 @@ proc paramTypesMatchAux(m: var TCandidate, f, a: PType, case r of isConvertible: + if f.skipTypes({tyRange}).kind in {tyInt, tyUInt}: + inc(m.convMatches) inc(m.convMatches) result = implicitConv(nkHiddenStdConv, f, arg, m, c) of isIntConv: diff --git a/tests/arithm/t1.nim b/tests/arithm/t1.nim index f9a87684e..36402da07 100644 --- a/tests/arithm/t1.nim +++ b/tests/arithm/t1.nim @@ -1,2 +1,14 @@ doAssert typeOf(1.int64 + 1.int) is int64 doAssert typeOf(1.uint64 + 1.uint) is uint64 +doAssert int64 is SomeNumber +doAssert int64 is (SomeNumber and not(uint32|uint64|uint|int)) +doAssert int64 is (not(uint32|uint64|uint|int)) +doAssert int isnot int64 +doAssert int64 isnot int +var myInt16 = 5i16 +var myInt: int +doAssert typeOf(myInt16 + 34) is int16 # of type `int16` +doAssert typeOf(myInt16 + myInt) is int # of type `int` +doAssert typeOf(myInt16 + 2i32) is int32 # of type `int32` +doAssert int32 isnot int64 +doAssert int32 isnot int |