mirror of
https://github.com/nim-lang/Nim.git
synced 2026-04-20 06:20:38 +00:00
* fix #7446 Generics: type mismatch 'SomeunsignedInt or Natural'
* try fix
(cherry picked from commit 083ea8f10c)
This commit is contained in:
@@ -1584,10 +1584,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:
|
||||
|
||||
10
tests/generics/t7446.nim
Normal file
10
tests/generics/t7446.nim
Normal file
@@ -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
|
||||
Reference in New Issue
Block a user