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

Weird compiler error when using nested generic types #11838

Closed
syhpoon opened this issue Jul 27, 2019 · 0 comments · Fixed by #24028
Closed

Weird compiler error when using nested generic types #11838

syhpoon opened this issue Jul 27, 2019 · 0 comments · Fixed by #24028

Comments

@syhpoon
Copy link

syhpoon commented Jul 27, 2019

simplified use-case:

import asyncdispatch

type
   R*[P] = object
      updates*: seq[P]

   D*[T, P] = ref object
      ps: seq[P]
      t: T

proc newD*[T, P](ps: seq[P], t: T): D[T, P] =
   D[T, P](ps: ps, t: t)

proc loop*[T, P](d: D[T, P]) =
   var results = newSeq[Future[R[P]]](10)

let d = newD[string, int](@[1], "")

d.loop()

and then user leorize provided even simpler version of the same issue:

type R*[T] = object

proc loop*[T]() =
   discard newSeq[R[R[T]]]()

loop[int]()

In both cases, trying to compile the code gives the following error:

Error: cannot instantiate Future
got: <T>
but expected: <T>

Expected Output

The code compiles or at least a helpful message is shown.

Version

$ nim -v
Nim Compiler Version 0.20.2 [Linux: amd64]
Compiled at 2019-07-17
Copyright (c) 2006-2019 by Andreas Rumpf

git hash: 88a0edba4b1a3d535b54336fd589746add54e937
active boot switches: -d:release
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants