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

checking object type for a pragma is not possible #7451

Closed
RSDuck opened this issue Mar 30, 2018 · 1 comment
Closed

checking object type for a pragma is not possible #7451

RSDuck opened this issue Mar 30, 2018 · 1 comment
Labels

Comments

@RSDuck
Copy link
Contributor

RSDuck commented Mar 30, 2018

type
  User {.exportc, packed.} = object
    id: int

import macros

macro test(t: typedesc): untyped =
  echo t.getType()[1].symbol.getImpl.treerepr

test(User)

the output doesn't contain any informations of the pragma:

TypeDef
  Sym "User"
  Empty
  ObjectTy
    Empty
    Empty
    RecList
      IdentDefs
        Ident ident"id"
        Sym "int"
        Empty

Also the procs hasCustomPragma and getCustomPragmaVal don't support types. But the documentation contains an example of a custom pragma on a object(https://nim-lang.org/docs/manual.html#implementation-specific-pragmas-custom-annotations)

Also see here https://forum.nim-lang.org/t/3705

@RSDuck
Copy link
Contributor Author

RSDuck commented Apr 8, 2018

I found another problem:
Because of the implicit dereference hasCustomPragma and getCustomPragma don't work with ref types (https://github.com/nim-lang/Nim/blob/master/lib/core/macros.nim#L1224 where n[0] should be n[0][0] in case it's of the kind nnkHiddenDeref)

@RSDuck RSDuck mentioned this issue Apr 11, 2018
Araq pushed a commit that referenced this issue Apr 14, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants