Allow typeof(nil) as generic parameter (#11869)

This commit is contained in:
Oscar Nihlgård 2019-08-03 10:16:07 +02:00 • committed by Arne Döring
commit bcfb540e57
2 changed files with 11 additions and 4 deletions

View file

@ -340,8 +340,6 @@ proc typeRel*(c: var TCandidate, f, aOrig: PType,
proc concreteType(c: TCandidate, t: PType; f: PType = nil): PType = proc concreteType(c: TCandidate, t: PType; f: PType = nil): PType =
case t.kind case t.kind
of tyNil:
result = nil # what should it be?
of tyTypeDesc: of tyTypeDesc:
if c.isNoCall: result = t if c.isNoCall: result = t
else: result = nil else: result = nil

View file

@ -2,5 +2,14 @@ discard """
targets: "c cpp" targets: "c cpp"
""" """
proc foo(v: type(nil)) = discard proc f1(v: typeof(nil)) = discard
foo nil f1(nil)
proc f2[T]() = discard
f2[typeof(nil)]()
proc f3(_: typedesc) = discard
f3(typeof(nil))
proc f4[T](_: T) = discard
f4(nil)