Skip to content

Implicitly generic functions can't instantiate dependant return types #7006

@RedBeard0531

Description

@RedBeard0531
type
  Node[T] = object
    val: T
    next: ref Node[T]
    
  HHSet[T, Key] = object
    data: seq[Node[T]]

proc rawGet(hhs:HHSet; key: hhs.Key): ptr Node[hhs.T] =
    return nil # body doesn't matter
    
var hhs: HHSet[string, cstring]
discard hhs.rawGet("hello".cstring)
in.nim(13, 12) template/generic instantiation from here
in.nim(9, 39) Error: cannot instantiate: 'result:type'

Changing rawGet to this works fine:

proc rawGet(hhs: HHSet; key: hhs.Key): auto =
    return cast[ptr Node[hhs.T]](nil) # body doesn't matter

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions