From 9bc30a1ff8afcaab3e18b71a3b05608a385ca95e Mon Sep 17 00:00:00 2001 From: Jason Beetham Date: Tue, 28 Mar 2023 20:50:56 -0600 Subject: [PATCH] Fix segfault caused by ensuring valueless statics are not evaluated (#21577) (cherry picked from commit c06623bf8ccfccf4788e9f4d2f044ab1bde6fe46) --- compiler/semtypinst.nim | 2 +- tests/statictypes/tstatictypes.nim | 20 ++++++++++++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/compiler/semtypinst.nim b/compiler/semtypinst.nim index c2bf3539c9..a3a444d092 100644 --- a/compiler/semtypinst.nim +++ b/compiler/semtypinst.nim @@ -201,7 +201,7 @@ proc hasValuelessStatics(n: PNode): bool = proc doThing(_: MyThing) ]# if n.safeLen == 0: - n.typ.kind == tyStatic + n.typ == nil or n.typ.kind == tyStatic else: for x in n: if hasValuelessStatics(x): diff --git a/tests/statictypes/tstatictypes.nim b/tests/statictypes/tstatictypes.nim index 5df3f35fd5..9b2d81b258 100644 --- a/tests/statictypes/tstatictypes.nim +++ b/tests/statictypes/tstatictypes.nim @@ -391,3 +391,23 @@ var sorted = newSeq[int](1000) for i in 0..