diff --git a/compiler/sigmatch.nim b/compiler/sigmatch.nim index e486f3a47f..6324b157b1 100644 --- a/compiler/sigmatch.nim +++ b/compiler/sigmatch.nim @@ -1568,8 +1568,11 @@ proc typeRel(c: var TCandidate, f, aOrig: PType, # set['a'..'z'] and set[char] have different representations result = isNone else: - # but we can convert individual elements of the constructor - result = isConvertible + if result >= isConvertible: + # but we can convert individual elements of the constructor + result = isConvertible + else: + result = isNone of tyPtr, tyRef: a = reduceToBase(a) if a.kind == f.kind: diff --git a/tests/proc/tgenericdefaultparam.nim b/tests/proc/tgenericdefaultparam.nim index 038110f5d5..5269d1e9fe 100644 --- a/tests/proc/tgenericdefaultparam.nim +++ b/tests/proc/tgenericdefaultparam.nim @@ -104,7 +104,7 @@ block: # issue #24484 foo[E]() proc bar[T](t: set[T] = {T(0), 5}) = - doAssert t == {0, 5} + doAssert t == {T(0), 5} bar[uint8]() doAssert not compiles(bar[string]()) diff --git a/tests/sets/twrongsetmatch.nim b/tests/sets/twrongsetmatch.nim new file mode 100644 index 0000000000..7360d876b1 --- /dev/null +++ b/tests/sets/twrongsetmatch.nim @@ -0,0 +1,16 @@ +# issue #25009 + +type EnumOne {.pure.} = enum + aaa + bbb + +type EnumTwo {.pure.} = enum + ccc + ddd + eee + +proc doStuff(e: set[EnumOne]) = + echo e + +doStuff({EnumTwo.ddd}) #[tt.Error + ^ type mismatch]#