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

Passing $ to a typed param of a macro yields a single nnkSym instead of a nnkClosedSymChoice #12831

Closed
liquidev opened this issue Dec 7, 2019 · 1 comment · Fixed by #24525

Comments

@liquidev
Copy link
Contributor

liquidev commented Dec 7, 2019

Because $ is overloaded, I would expect an nnkClosedSymChoice to be returned.

Example

import macros

macro dumpRepr(x: typed): untyped =
  result = newLit(x.treeRepr & "\n")
echo dumpRepr(`$`)

Current Output

Sym "$"

Expected Output

ClosedSymChoice
  Sym "$"
  Sym "$"
  Sym "$"
  Sym "$"
  Sym "$"
  Sym "$"
  Sym "$"
  Sym "$"
  Sym "$"
  Sym "$"
  Sym "$"
  Sym "$"
  Sym "$"
  Sym "$"
  Sym "$"
  Sym "$"
  Sym "$"
  Sym "$"
  Sym "$"
  Sym "$"
  Sym "$"
  Sym "$"

Additional Information

  • dumpRepr(typeof `$`) works, but wraps the node in an nnkTypeOfExpr
  • This issue is a problem for euwren, since you can't wrap stringifying procs without using a wrapper proc
$ nim -v
Nim Compiler Version 1.0.4 [Linux: amd64]
Compiled at 2019-11-27
Copyright (c) 2006-2019 by Andreas Rumpf

git hash: c8998c498f5e2a0874846eb31309e1d1630faca6
active boot switches: -d:release
@metagn
Copy link
Collaborator

metagn commented Nov 3, 2024

Works in 2.2 probably because of #23033 etc

metagn added a commit to metagn/Nim that referenced this issue Dec 8, 2024
@Araq Araq closed this as completed in aeb3fe9 Dec 9, 2024
narimiran pushed a commit that referenced this issue Jan 14, 2025
closes #6013, closes #7009, closes #9190, closes #12487, closes #12831,
closes #13184, closes #13252, closes #14860, closes #14877, closes
#14894, closes #14917, closes #16153, closes #16439, closes #17779,
closes #18074, closes #18202, closes #18314, closes #18648, closes
#19063, closes #19446, closes #20065, closes #20367, closes #22126,
closes #22820, closes #22888, closes #23020, closes #23287, closes
#23510

(cherry picked from commit aeb3fe9)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants