From 82896abcbe2021af249f2a4231492ec4792ee662 Mon Sep 17 00:00:00 2001 From: jcosborn Date: Tue, 9 Oct 2018 06:34:03 -0500 Subject: [PATCH] fixes #4435 (#9185) (cherry picked from commit dd659867955d87affde0b6271cc9bf86208462dc) --- compiler/sigmatch.nim | 2 +- tests/distinct/t4435.nim | 21 +++++++++++++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) create mode 100644 tests/distinct/t4435.nim diff --git a/compiler/sigmatch.nim b/compiler/sigmatch.nim index e0fa74db58..cc1aaa074d 100644 --- a/compiler/sigmatch.nim +++ b/compiler/sigmatch.nim @@ -1292,7 +1292,7 @@ proc typeRelImpl(c: var TCandidate, f, aOrig: PType, of tyDistinct: if a.kind == tyDistinct: if sameDistinctTypes(f, a): result = isEqual - elif f.base.kind == tyAnything: result = isGeneric + #elif f.base.kind == tyAnything: result = isGeneric # issue 4435 elif c.coerceDistincts: result = typeRel(c, f.base, a) elif a.kind == tyNil and f.base.kind in NilableTypes: result = f.allowsNil diff --git a/tests/distinct/t4435.nim b/tests/distinct/t4435.nim new file mode 100644 index 0000000000..4d9979fabf --- /dev/null +++ b/tests/distinct/t4435.nim @@ -0,0 +1,21 @@ +discard """ + output: ''' +A +A +''' +""" + +type + A[T] = distinct T + B[T] = distinct T + +proc foo[T](x:A[T]) = echo "A" +proc foo[T](x:B[T]) = echo "B" +proc bar(x:A) = echo "A" +proc bar(x:B) = echo "B" + +var + a:A[int] + +foo(a) # fine +bar(a) # testdistinct.nim(14, 4) Error: ambiguous call; both testdistinct.bar(x: A) and testdistinct.bar(x: B) match for: (A[system.int])