diff options
-rw-r--r-- | compiler/sigmatch.nim | 3 | ||||
-rw-r--r-- | tests/generics/t7446.nim | 10 |
2 files changed, 11 insertions, 2 deletions
diff --git a/compiler/sigmatch.nim b/compiler/sigmatch.nim index 5448d8dcd..60b0fe612 100644 --- a/compiler/sigmatch.nim +++ b/compiler/sigmatch.nim @@ -1595,10 +1595,9 @@ proc typeRel(c: var TCandidate, f, aOrig: PType, c.inheritancePenalty = 0 let x = typeRel(c, branch, aOrig, flags) maxInheritance = max(maxInheritance, c.inheritancePenalty) - # 'or' implies maximum matching result: if x > result: result = x - if result >= isSubtype: + if result >= isIntConv: if result > isGeneric: result = isGeneric bindingRet result else: diff --git a/tests/generics/t7446.nim b/tests/generics/t7446.nim new file mode 100644 index 000000000..71aa8f0e8 --- /dev/null +++ b/tests/generics/t7446.nim @@ -0,0 +1,10 @@ +proc foo(x: Natural or SomeUnsignedInt):int = + when x is int: + result = 1 + else: + result = 2 +let a = 10 +doAssert foo(a) == 1 + +let b = 10'u8 +doAssert foo(b) == 2 \ No newline at end of file |