From 2c98b4943efb48cec01a63154bdf2cfb9da61714 Mon Sep 17 00:00:00 2001 From: LemonBoy Date: Mon, 2 Jul 2018 00:49:03 +0200 Subject: [PATCH] Fix crash with static and anonymous procs (#8171) Fixes #6077 --- compiler/semtypes.nim | 2 +- tests/statictypes/tstatictypes.nim | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/compiler/semtypes.nim b/compiler/semtypes.nim index dfd4247054..17420111f1 100644 --- a/compiler/semtypes.nim +++ b/compiler/semtypes.nim @@ -873,7 +873,7 @@ proc liftParamType(c: PContext, procKind: TSymKind, genericParams: PNode, if base.isMetaType and procKind == skMacro: localError(c.config, info, errMacroBodyDependsOnGenericTypes % paramName) result = addImplicitGeneric(c.newTypeWithSons(tyStatic, @[base])) - result.flags.incl({tfHasStatic, tfUnresolved}) + if result != nil: result.flags.incl({tfHasStatic, tfUnresolved}) of tyTypeDesc: if tfUnresolved notin paramType.flags: diff --git a/tests/statictypes/tstatictypes.nim b/tests/statictypes/tstatictypes.nim index 789bd75886..2a3b7332df 100644 --- a/tests/statictypes/tstatictypes.nim +++ b/tests/statictypes/tstatictypes.nim @@ -107,3 +107,12 @@ when true: assert aw2.data.high == 6 assert aw3.data.high == 9 +# #6077 +block: + type + Backend = enum + Cpu + + Tensor[B: static[Backend]; T] = object + + BackProp[B: static[Backend],T] = proc (gradient: Tensor[B,T]): Tensor[B,T]