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

cannot get pragma of attribute in macro #11511

Open
zraktvor opened this issue Jun 16, 2019 · 1 comment
Open

cannot get pragma of attribute in macro #11511

zraktvor opened this issue Jun 16, 2019 · 1 comment
Assignees

Comments

@zraktvor
Copy link

pragmas of attributes are not recognized in macros.

Example

import macros

template myAttr {. pragma .}

type TObj = object
    a {. myAttr .}: int
  

macro hasMyAttr*(t: typedesc): untyped =
  let objTy = t.getType[1].getType
  let recList = objTy[2]
  let sym = recList[0]
  assert sym.kind == nnkSym and sym.strVal == "a"
  let hasAttr = sym.hasCustomPragma(myAttr)
  newLit(hasAttr)

echo hasMyAttr(TObj)

Current Output

false

Expected Output

true

Additional Information

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

git hash: e7471cebae2a404f3e4239f199f5a0c422484aac
active boot switches: -d:release

@awr1
Copy link
Contributor

awr1 commented Jun 16, 2019

getType() does not carry in pragma info, curiously...

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