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

[bug?] getAST from a typed macro having no type #7739

Open
mratsim opened this issue Apr 30, 2018 · 1 comment
Open

[bug?] getAST from a typed macro having no type #7739

mratsim opened this issue Apr 30, 2018 · 1 comment

Comments

@mratsim
Copy link
Collaborator

mratsim commented Apr 30, 2018

Mentionned in #7719/nim-lang/RFCs#44, feel free to close if it works as expected.

Quote do works but getAST doesn't even though I think it should be equivalent here:

import macros, typetraits

proc getSubType(T: NimNode): NimNode =
  echo getTypeInst(T).treerepr
  result = getTypeInst(T)[1]

macro typed_helper(x: typed): untyped =

  result = getSubType(x)

macro untyped_heavylifting(x: varargs[untyped]): untyped =

  let first = x[0]

  # result = quote do: # Works
  #   typed_helper(`first`)

  result = getAST(typed_helper(first)) # Node has no type

var a: seq[int]
echo untyped_heavylifting(a)
@krux02
Copy link
Contributor

krux02 commented May 2, 2018

It should be a proper error message that this is not supported.

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

4 participants