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

[Compiler Crash] - getAST + hasCustomPragma #7615

Closed
mratsim opened this issue Apr 15, 2018 · 1 comment

Comments

Projects
None yet
3 participants
@mratsim
Copy link
Collaborator

commented Apr 15, 2018

While trying to show an example on the forum https://forum.nim-lang.org/t/3757, I stumbled upon this sempass2 crash with getAST and hasCustomPragma.

import macros

template table(name: string) {.pragma.}

type
   User {.table("tuser").} = object
      id: int
      name: string
      age: int

echo User.hasCustomPragma(table)


## crash: Error: internal error: (filename: "sempass2.nim", line: 560, column: 19)
macro m1(T: typedesc): untyped =
  getAST hasCustomPragma(T, table)
echo m1(User) # Oops crash


## This works
macro m2(T: typedesc): untyped =
  result = quote do:
    `T`.hasCustomPragma(table)
echo m2(User)

@Yardanico Yardanico added the Crash label Apr 15, 2018

@cooldome

This comment has been minimized.

Copy link
Member

commented Apr 15, 2018

You currently can't call a macro from another macro

@narimiran narimiran closed this in 3845faf May 29, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.