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

Capturing any parameter of a typed macro in a closure will cause it to evaluate to nil #18352

Open
alaviss opened this issue Jun 25, 2021 · 0 comments
Labels
CPS bugs/pulls related to the cps project Macros

Comments

@alaviss
Copy link
Collaborator

alaviss commented Jun 25, 2021

Example

import macros

func run(fn: proc()) = fn()

macro foo(T: typed): untyped =
  proc bar() =
    echo repr T
  run(bar)
  echo repr T
 
foo(int)

Current Output

nil
nil

Expected Output

int
int

Additional Information

  • This can be workaround by shadowing the parameter before the closure declaration
$ nim -v
Nim Compiler Version 1.5.1 [Linux: amd64]
Compiled at 2021-06-24
Copyright (c) 2006-2021 by Andreas Rumpf

git hash: 0f91b67f5c15328330f74a8769aed9961940aab2
active boot switches: -d:release -d:nimUseLinenoise
@alaviss alaviss added Macros CPS bugs/pulls related to the cps project labels Jun 25, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CPS bugs/pulls related to the cps project Macros
Projects
None yet
Development

No branches or pull requests

1 participant