mirror of
https://github.com/nim-lang/Nim.git
synced 2025-12-29 09:24:36 +00:00
@@ -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
|
||||
|
||||
21
tests/distinct/t4435.nim
Normal file
21
tests/distinct/t4435.nim
Normal file
@@ -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])
|
||||
Reference in New Issue
Block a user