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

future/sugar => syntax breaks with generics #7816

Closed
bluenote10 opened this issue May 12, 2018 · 3 comments
Closed

future/sugar => syntax breaks with generics #7816

bluenote10 opened this issue May 12, 2018 · 3 comments
Labels

Comments

@bluenote10
Copy link
Contributor

bluenote10 commented May 12, 2018

Recently I'm getting all kinds of compilation errors when using the future/sugar => syntax. I now noticed that it is related to generic procs:

import sequtils
import sugar

proc tester[T](x: T) =
  let test = toSeq(0..5).map(i => newSeq[int]())

tester(1)

Error:

test.nim(7, 7) template/generic instantiation from here
test.nim(5, 32) template/generic instantiation from here
lib/system.nim(3559, 14) Error: cannot instantiate: 'T'

The expression does work when it appears in a non-generic context, and I'm pretty sure such code used to work before.

@Araq
Copy link
Member

Araq commented May 15, 2018

This is a though one. Can I have the commit that introduced the regression please?

@bluenote10
Copy link
Contributor Author

I tried to find it, but even this is tough :). The exact example I have given also seems to fail with fairly old versions of Nim. I have some other variants of this failure, I'll have to see if I can bisect them. Maybe it isn't a regression after all, and I just happened to run into it much more often now...

@timotheecour
Copy link
Member

@bluenote10 @Araq I doubt it ever worked; but my PR #8679 will fix this:

when defined(case2):
  import sequtils
  import sugar

  proc tester[T](x: T) =
    let test = toSeq(0..5).map(i => newSeq[int]())
    echo test

  tester(1)

when defined(case3):
  import sequtils
  proc tester[T](x: T) =
    let test = toSeq(0..5).map2(i => newSeq[int]()) # pending renaming map2 to map
    echo test

  tester(1)

rnim -d:case2 tests/nim/lambda/t01_lambda_exp3.nim
nim c --nimcache:/tmp/nim//nimcache/ -o:/tmp/nim//app -r -d:case2 tests/nim/lambda/t01_lambda_exp3.nim

@[@[], @[], @[], @[], @[], @[]]

@Araq Araq added Severe and removed Regression labels Aug 30, 2018
Araq added a commit that referenced this issue May 15, 2019
@Araq Araq closed this as completed in e265457 May 15, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants