Skip to content

Cannot instantiate T from => in generic #7399

Closed
@bluenote10

Description

@bluenote10

There seems to be an issue with future's => and generics:

import sequtils, future

proc f*[T](x: T) =
  let other = @[1, 2, 3]
  var mapped = toSeq(0 ..< other.len).map(i => (other[i], i))

f(1)

Produces: lib/system.nim(3549, 14) Error: cannot instantiate: 'T'

The issue disappears:

  • when f is not generic
  • when using other expressions like i => (i, i)
  • when writing the expression verbosely toSeq(0 ..< other.len).map(proc(i: int): (int, int) = (other[i], i))

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions