From 32f335f594d7007fabe4232a63f51137d7fb6cc1 Mon Sep 17 00:00:00 2001 From: Timothee Cour Date: Wed, 24 Jun 2020 23:00:19 -0700 Subject: [PATCH] fix #14802 (#14803) --- compiler/ast.nim | 3 ++- tests/statictypes/tstatictypes.nim | 7 +++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/compiler/ast.nim b/compiler/ast.nim index 40fd402091..b57ee542dd 100644 --- a/compiler/ast.nim +++ b/compiler/ast.nim @@ -1841,7 +1841,8 @@ proc isInfixAs*(n: PNode): bool = return n.kind == nkInfix and n[0].kind == nkIdent and n[0].ident.s == "as" proc findUnresolvedStatic*(n: PNode): PNode = - if n.kind == nkSym and n.typ.kind == tyStatic and n.typ.n == nil: + # n.typ == nil: see issue #14802 + if n.kind == nkSym and n.typ != nil and n.typ.kind == tyStatic and n.typ.n == nil: return n for son in n: diff --git a/tests/statictypes/tstatictypes.nim b/tests/statictypes/tstatictypes.nim index 1aab6e1241..2a8d09dbf4 100644 --- a/tests/statictypes/tstatictypes.nim +++ b/tests/statictypes/tstatictypes.nim @@ -216,3 +216,10 @@ block: # #12713 proc test(c: static string) = discard #Remove this and it compiles proc test(c: Cell) = discard test Cell() + +block: # issue #14802 + template fn(s: typed): untyped = + proc bar() = discard + 12 + const myConst = static(fn(1)) + doAssert myConst == 12