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

Open
liquidev opened this issue Dec 7, 2019 · 1 comment

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

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

No branches or pull requests

2 participants