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

Custom pragma of function argument is not in AST #24702

Closed
yglukhov opened this issue Feb 19, 2025 · 0 comments · Fixed by #24711
Closed

Custom pragma of function argument is not in AST #24702

yglukhov opened this issue Feb 19, 2025 · 0 comments · Fixed by #24711

Comments

@yglukhov
Copy link
Member

yglukhov commented Feb 19, 2025

Description

# test.nim
import macros
template attr*() {.pragma.}
proc foo(a {.attr.}: int) = discard
macro showImpl(a: typed) =
  echo treeRepr getImpl(a)
showImpl(foo)
nim c test.nim

Nim Version

Nim Compiler Version 2.3.1 [Linux: amd64]
Compiled at 2025-01-21
Copyright (c) 2006-2025 by Andreas Rumpf

git hash: 793baf3
active boot switches: -d:release

Current Output

ProcDef
  Sym "foo"
  Empty
  Empty
  FormalParams
    Empty
    IdentDefs
      Sym "a"
      Sym "int"
      Empty
  Empty
  Empty
  DiscardStmt
    Empty

Expected Output

ProcDef
  Ident "foo"
  Empty
  Empty
  FormalParams
    Empty
    IdentDefs
      PragmaExpr
        Ident "a"
        Pragma
          Ident "attr"
      Ident "int"
      Empty
  Empty
  Empty
  StmtList
    DiscardStmt
      Empty

Known Workarounds

No response

Additional Information

The following code behaves as expected.

dumpTree:
    proc foo(a {.attr.}: int) = discard

But getImpl returns AST without the pragma.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant