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

Comment isn't flattened in template def AST #21367

Open
ire4ever1190 opened this issue Feb 14, 2023 · 0 comments
Open

Comment isn't flattened in template def AST #21367

ire4ever1190 opened this issue Feb 14, 2023 · 0 comments

Comments

@ire4ever1190
Copy link
Contributor

Description

Comment nodes are not flattened when they are the single child inside a statement node when in a template definition. They are flattened inside other routine definitions like macros and procs

Example

import macros

template test(docs) =
  proc foo() =
    docs
    discard

  template bar() = 
    docs
    discard
  
macro dump(x: typed) =
  echo x.treeRepr

dump:
  test:
    ## Some documentation

Nim Version

Nim Compiler Version 1.9.1 [Linux: amd64]
Compiled at 2023-02-01
Copyright (c) 2006-2023 by Andreas Rumpf

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

Current Output

StmtList
    ProcDef
      Sym "foo"
      Empty
      Empty
      FormalParams
        Empty
      Empty
      Empty
      StmtList 
        CommentStmt "Some documentation" <-- Comment has been taken out of statement list
        DiscardStmt
          Empty
    TemplateDef
      Sym "bar"
      Empty
      Empty
      FormalParams
        Empty
      Empty
      Empty
      StmtList
        StmtList <-- Inside a statement list which means the comment won't be rendered in docs
          CommentStmt "Some documentation"
        DiscardStmt
          Empty

Expected Output

StmtList
    ProcDef
      Sym "foo"
      Empty
      Empty
      FormalParams
        Empty
      Empty
      Empty
      StmtList 
        CommentStmt "Some documentation"
        DiscardStmt
          Empty
    TemplateDef
      Sym "bar"
      Empty
      Empty
      FormalParams
        Empty
      Empty
      Empty
      StmtList
        CommentStmt "Some documentation"
        DiscardStmt
          Empty

Possible Solution

No response

Additional Information

No response

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

No branches or pull requests

1 participant