From 5a03eea518ba3cfeaa9f57ef0b6f1cf7bc8ed1d9 Mon Sep 17 00:00:00 2001 From: Andreas Rumpf Date: Mon, 2 Sep 2019 17:48:06 +0200 Subject: revert #12100; typeof(nil) is weird enough, don't allow it as the return type --- compiler/types.nim | 2 +- tests/ccgbugs/tnil_type.nim | 3 --- 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/compiler/types.nim b/compiler/types.nim index 29d880ff6..e2de8280e 100644 --- a/compiler/types.nim +++ b/compiler/types.nim @@ -1310,7 +1310,7 @@ proc typeAllowedAux(marker: var IntSet, typ: PType, kind: TSymKind, tyNone, tyForward, tyFromExpr: result = t of tyNil: - if kind != skConst and kind != skParam and kind != skResult: result = t + if kind != skConst and kind != skParam: result = t of tyString, tyBool, tyChar, tyEnum, tyInt..tyUInt64, tyCString, tyPointer: result = nil of tyOrdinal: diff --git a/tests/ccgbugs/tnil_type.nim b/tests/ccgbugs/tnil_type.nim index 12310dae9..9921b24a3 100644 --- a/tests/ccgbugs/tnil_type.nim +++ b/tests/ccgbugs/tnil_type.nim @@ -13,6 +13,3 @@ f3(typeof(nil)) proc f4[T](_: T) = discard f4(nil) - -proc f5(): typeof(nil) = nil -discard f5() -- cgit 1.4.1-2-gfad0