diff options
-rw-r--r-- | compiler/sigmatch.nim | 2 | ||||
-rw-r--r-- | tests/distinct/tdistinct.nim | 8 |
2 files changed, 9 insertions, 1 deletions
diff --git a/compiler/sigmatch.nim b/compiler/sigmatch.nim index 39dcfedcf..003bca646 100644 --- a/compiler/sigmatch.nim +++ b/compiler/sigmatch.nim @@ -1293,7 +1293,7 @@ proc typeRel(c: var TCandidate, f, aOrig: PType, inc(c.inheritancePenalty, depth) result = isSubtype of tyDistinct: - skipOwned(a) + a = a.skipTypes({tyOwned, tyGenericInst, tyRange}) if a.kind == tyDistinct: if sameDistinctTypes(f, a): result = isEqual #elif f.base.kind == tyAnything: result = isGeneric # issue 4435 diff --git a/tests/distinct/tdistinct.nim b/tests/distinct/tdistinct.nim index c6bfb2490..2c0196745 100644 --- a/tests/distinct/tdistinct.nim +++ b/tests/distinct/tdistinct.nim @@ -6,6 +6,7 @@ false false false false +Foo ''' """ @@ -98,3 +99,10 @@ proc `<=`(a, b: Id): bool {.borrow.} var xs: array[Id, bool] for x in xs: echo x # type mismatch: got (T) but expected 'bool' + +# bug #11715 + +type FooD = distinct int +proc `<=`(a, b: FooD): bool {.borrow.} + +for f in [FooD(0): "Foo"]: echo f |