Skip to content

Commit c446c0f

Browse files
authored
fixes nim-lang#13378 [backport] (nim-lang#13392)
1 parent eec07b4 commit c446c0f

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

compiler/sigmatch.nim

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1942,6 +1942,8 @@ proc localConvMatch(c: PContext, m: var TCandidate, f, a: PType,
19421942

19431943
if result != nil:
19441944
if result.typ == nil: return nil
1945+
# bug #13378, ensure we produce a real generic instantiation:
1946+
result = c.semExpr(c, call)
19451947
# resulting type must be consistent with the other arguments:
19461948
var r = typeRel(m, f[0], result.typ)
19471949
if r < isGeneric: return nil

tests/generics/tgeneric0.nim

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ discard """
44
0
55
float32
66
float32
7+
(name: "Resource 1", readers: ..., writers: ...)
78
'''
89
"""
910

@@ -124,3 +125,18 @@ block tgeneric5:
124125
echo T
125126

126127
bar(0.0'f32)
128+
129+
# bug #13378
130+
131+
type
132+
Resource = ref object of RootObj
133+
name: string
134+
readers, writers: seq[RenderTask]
135+
136+
RenderTask = ref object
137+
name: string
138+
139+
var res = Resource(name: "Resource 1")
140+
141+
(proc (r: typeof(res)) =
142+
echo r[])(res)

0 commit comments

Comments
 (0)