mirror of
https://github.com/nim-lang/Nim.git
synced 2025-12-31 18:32:11 +00:00
Allow typeof(nil) as generic parameter (#11869)
(cherry picked from commit bcfb540e57)
This commit is contained in:
committed by
narimiran
parent
64d1159054
commit
ccc611e06d
@@ -331,8 +331,6 @@ proc typeRel*(c: var TCandidate, f, aOrig: PType,
|
||||
|
||||
proc concreteType(c: TCandidate, t: PType; f: PType = nil): PType =
|
||||
case t.kind
|
||||
of tyNil:
|
||||
result = nil # what should it be?
|
||||
of tyTypeDesc:
|
||||
if c.isNoCall: result = t
|
||||
else: result = nil
|
||||
|
||||
@@ -2,5 +2,14 @@ discard """
|
||||
targets: "c cpp"
|
||||
"""
|
||||
|
||||
proc foo(v: type(nil)) = discard
|
||||
foo nil
|
||||
proc f1(v: typeof(nil)) = discard
|
||||
f1(nil)
|
||||
|
||||
proc f2[T]() = discard
|
||||
f2[typeof(nil)]()
|
||||
|
||||
proc f3(_: typedesc) = discard
|
||||
f3(typeof(nil))
|
||||
|
||||
proc f4[T](_: T) = discard
|
||||
f4(nil)
|
||||
Reference in New Issue
Block a user