Merge pull request #4572 from oderwat/distinct-nil

Allowing `nil` for distinct types where the base type is nilable
This commit is contained in:
Andreas Rumpf 2016-08-05 20:11:28 +02:00 • committed by GitHub
commit df0baefb12
2 changed files with 49 additions and 0 deletions

View file

@ -900,6 +900,8 @@ proc typeRel(c: var TCandidate, f, aOrig: PType, doBind = true): TTypeRelation =
if sameDistinctTypes(f, a): result = isEqual
elif f.base.kind == tyAnything: result = isGeneric
elif c.coerceDistincts: result = typeRel(c, f.base, a)
elif a.kind == tyNil and f.base.kind in NilableTypes:
result = f.allowsNil
elif c.coerceDistincts: result = typeRel(c, f.base, a)
of tySet:
if a.kind == tySet: