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

Escaping the quote op doesn't seem to work #11151

Closed
bluenote10 opened this issue May 1, 2019 · 2 comments
Closed

Escaping the quote op doesn't seem to work #11151

bluenote10 opened this issue May 1, 2019 · 2 comments

Comments

@bluenote10
Copy link
Contributor

My interpretation of the quote docstring is that doubling up the quote op should escape it, i.e., I expected the following to work:

Example

import macros

static:
  let node = quote:
    ``+``(a, b)

Current Output

test.nim(5, 6) Error: identifier expected, but got '`'

Expected Output

Should compile.

Additional Information

$ nim -v
Nim Compiler Version 0.19.9 [Linux: amd64]
Compiled at 2019-04-13
Copyright (c) 2006-2019 by Andreas Rumpf

git hash: f6ad071a46a2bec57db453343d8d8b75d3d16ac2
active boot switches: -d:release
@bluenote10
Copy link
Contributor Author

Hm, maybe I don't have to double up the backticks? What I'm actually trying to achieve is passing an AST involving backticks to a compile time proc:

proc test(n: NimNode) =
  echo n.treeRepr

static:
  test:
    quote:
      `+`(a, b)

which errors with test.nim(13, 8) Error: cannot generate VM code for + but works fine as long as the AST doesn't contain backticks.

On the other hand I noticed that this works in general:

import macros

dumpTree:
  quote:
    `+`(a, b)

@mratsim mratsim added the Macros label May 1, 2019
@mratsim
Copy link
Collaborator

mratsim commented May 1, 2019

Duplicate: #7589

See also RFC: nim-lang/RFCs#122
and PR: #10446

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