From 14e1f82f426e6eaf027292ab3fa4472cf0374262 Mon Sep 17 00:00:00 2001 From: Andreas Rumpf Date: Tue, 11 Feb 2020 23:48:41 +0100 Subject: [PATCH] fixes #13378 [backport] (#13392) (cherry picked from commit c446c0f57af03e0be3a5b39be48d14676e7deebe) --- compiler/sigmatch.nim | 2 ++ tests/generics/tgeneric0.nim | 16 ++++++++++++++++ 2 files changed, 18 insertions(+) diff --git a/compiler/sigmatch.nim b/compiler/sigmatch.nim index 5fa7c995a472..a15df695c2ed 100644 --- a/compiler/sigmatch.nim +++ b/compiler/sigmatch.nim @@ -1945,6 +1945,8 @@ proc localConvMatch(c: PContext, m: var TCandidate, f, a: PType, if result != nil: if result.typ == nil: return nil + # bug #13378, ensure we produce a real generic instantiation: + result = c.semExpr(c, call) # resulting type must be consistent with the other arguments: var r = typeRel(m, f.sons[0], result.typ) if r < isGeneric: return nil diff --git a/tests/generics/tgeneric0.nim b/tests/generics/tgeneric0.nim index ca012734b9ef..ae4820f5719e 100644 --- a/tests/generics/tgeneric0.nim +++ b/tests/generics/tgeneric0.nim @@ -4,6 +4,7 @@ discard """ 0 float32 float32 +(name: "Resource 1", readers: ..., writers: ...) ''' """ @@ -124,3 +125,18 @@ block tgeneric5: echo T bar(0.0'f32) + +# bug #13378 + +type + Resource = ref object of RootObj + name: string + readers, writers: seq[RenderTask] + + RenderTask = ref object + name: string + +var res = Resource(name: "Resource 1") + +(proc (r: typeof(res)) = + echo r[])(res)