Skip to content

Commit

Permalink
fixes nim-lang#13378 [backport] (nim-lang#13392)
Browse files Browse the repository at this point in the history
(cherry picked from commit c446c0f)
  • Loading branch information
Araq authored and narimiran committed Feb 19, 2020
1 parent 2304af2 commit 14e1f82
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
2 changes: 2 additions & 0 deletions compiler/sigmatch.nim
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
16 changes: 16 additions & 0 deletions tests/generics/tgeneric0.nim
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ discard """
0
float32
float32
(name: "Resource 1", readers: ..., writers: ...)
'''
"""

Expand Down Expand Up @@ -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)

0 comments on commit 14e1f82

Please sign in to comment.