From ccc611e06d820a398e796ae85ab47e04eb97d50f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oscar=20Nihlg=C3=A5rd?= Date: Sat, 3 Aug 2019 10:16:07 +0200 Subject: [PATCH] Allow typeof(nil) as generic parameter (#11869) (cherry picked from commit bcfb540e576603019dd1ac76ba4f8c9774e05943) --- compiler/sigmatch.nim | 2 -- tests/ccgbugs/tnil_type.nim | 13 +++++++++++-- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/compiler/sigmatch.nim b/compiler/sigmatch.nim index 6762c9f440..f60e084db0 100644 --- a/compiler/sigmatch.nim +++ b/compiler/sigmatch.nim @@ -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 diff --git a/tests/ccgbugs/tnil_type.nim b/tests/ccgbugs/tnil_type.nim index 44ecf1cc91..b57e64513b 100644 --- a/tests/ccgbugs/tnil_type.nim +++ b/tests/ccgbugs/tnil_type.nim @@ -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) \ No newline at end of file