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

Injected symbol is not visible in generic procedure #15693

Open
haxscramper opened this issue Oct 23, 2020 · 1 comment
Open

Injected symbol is not visible in generic procedure #15693

haxscramper opened this issue Oct 23, 2020 · 1 comment

Comments

@haxscramper
Copy link
Contributor

haxscramper commented Oct 23, 2020

Identifier identifier in template is visible in regular code, but fails compilation with undeclared identifier error when used in generic procedure.

Example

template getSome(val: typed, injected: untyped): untyped =
  let injected = val

block:
  123.getSome(resVal)
  assert resVal == 123
  discard resVal
  
proc g[T](arg: T) =
  arg.getSome(resVal)
  assert resVal == arg # works fine!
  discard resVal # fails to compile

g(12)

Current Output

/usercode/in.nim(14, 11) Error: undeclared identifier: 'resVal'

Expected Output

No compilation errors

Compiler version

$ nim -v
Nim Compiler Version 1.4.0 [Linux: amd64]
Compiled at 2020-10-16
Copyright (c) 2006-2020 by Andreas Rumpf

git hash: bdcd87afca238a0a7b2c70971827cf9172817b12
active boot switches: -d:release -d:danger
@timotheecour
Copy link
Member

timotheecour commented Oct 23, 2020

can you minimize to something that doesn't have any imports?
also {.inject.} doesnt' seem needed since injected is a template argument, IIRC

might be a duplicate but I don't remember which issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants