Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
RedBeard0531 opened this issue Jan 1, 2018 · 0 comments
Open

Comments

@RedBeard0531
Copy link
Contributor

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants