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

templates (e.g. sequtils.toSeq) often shadow `result` #10732

pb-cdunn opened this issue Feb 24, 2019 · 2 comments


None yet
3 participants
Copy link

commented Feb 24, 2019

Not new. I see this all the time. If you tell me the solution (e.g. what identifier to use instead of result, and maybe template code should be within a block), I'd be happy to submit a PR.


foo.nim(195, 128) template/generic instantiation from here
Nim/lib/pure/collections/sequtils.nim(532, 9) Warning: shadowed identifier: 'result' [ShadowIdent]
      var result: seq[type(iter)] = @[]
proc log*(msgs: varargs[string]) =
  for s in msgs:
    write(stderr, s)
  write(stderr, '\l')

195       log("In ... ", $sequtils.toSeq(...))
$ nim -v
Nim Compiler Version 0.19.4 [Linux: amd64]
git hash: b6d96cafc8bcad1f3d32f2910b25cd11a93f7751
active boot switches: -d:release

This comment has been minimized.

Copy link

commented Feb 24, 2019

Another example:

foo.nim(168, 22) template/generic instantiation from here
Nim/lib/pure/collections/sets.nim(235, 21) template/generic instantiation from here
Nim/lib/pure/collections/sets.nim(168, 15) template/generic instantiation from here
Nim/lib/pure/collections/sets.nim(162, 7) Warning: shadowed identifier: 'hc' [ShadowIdent]
    var hc = hash(key)

 161 template genHash(key: typed): Hash =
 162   var hc = hash(key)
 163   if hc == 0:       # This almost never taken branch should be very predictable.
 164     hc = 314159265  # Value doesn't matter; Any non-zero favorite is fine.
 165   hc

This comment has been minimized.

Copy link

commented Feb 25, 2019

IMO the warning should be removed. There is nothing wrong with "shadowing", as we can see, it is a basic composability requirement for non-toy languages with a macro system.

narimiran added a commit to narimiran/Nim that referenced this issue Apr 16, 2019

narimiran added a commit to narimiran/Nim that referenced this issue Apr 16, 2019

@Araq Araq closed this in 43832f8 Apr 17, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.