Skip to content

nnkDo node disappears when it has no arguments #12114

@krux02

Description

@krux02

In the untyped ast, a node of nnkDo with no arguments is omitted. This makes it indestinguishable from a stmtListExpr without a do block.

Example

import macros

dumpTree:
  foobar("abc") do:
    echo 1

  foobar("abc") do(abc):
    echo 1

  foobar("abc", proc() = echo 1)

Current Output

StmtList
  Call
    Ident "foobar"
    StrLit "abc"
    StmtList
      Command
        Ident "echo"
        IntLit 1
  Call
    Ident "foobar"
    StrLit "abc"
    Do
      Empty
      Empty
      Empty
      FormalParams
        Empty
        IdentDefs
          Ident "abc"
          Empty
          Empty
      Empty
      Empty
      StmtList
        Command
          Ident "echo"
          IntLit 1
  Call
    Ident "foobar"
    StrLit "abc"
    Lambda
      Empty
      Empty
      Empty
      FormalParams
        Empty
      Empty
      Empty
      StmtList
        Command
          Ident "echo"
          IntLit 1

Expected Output


StmtList
  Call
    Ident "foobar"
    StrLit "abc"
    Do
      Empty
      Empty
      Empty
      FormalParams
        Empty
      Empty
      Empty
      StmtList
        Command
          Ident "echo"
          IntLit 1
  Call
    Ident "foobar"
    StrLit "abc"
    Do
      Empty
      Empty
      Empty
      FormalParams
        Empty
        IdentDefs
          Ident "abc"
          Empty
          Empty
      Empty
      Empty
      StmtList
        Command
          Ident "echo"
          IntLit 1
  Call
    Ident "foobar"
    StrLit "abc"
    Lambda
      Empty
      Empty
      Empty
      FormalParams
        Empty
      Empty
      Empty
      StmtList
        Command
          Ident "echo"
          IntLit 1

Additional Information

This issue is related: #12110

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions