arnetheduck / nph

An opinionated code formatter for Nim
Other
77 stars 12 forks source link

Fails with `do ():` syntax #11

Closed ire4ever1190 closed 6 months ago

ire4ever1190 commented 6 months ago

Using do () syntax to pass a proc fails

Input

foo do ():
  echo "test"

Formatted

foo do :
  echo "test"

PRE

{
  "kind": "nkDo",
  "sons": [
    {
      "kind": "nkEmpty",
      "typ": 
    },
    {
      "kind": "nkEmpty",
      "typ": 
    },
    {
      "kind": "nkEmpty",
      "typ": 
    },
    {
      "kind": "nkFormalParams",
      "sons": [
        {
          "kind": "nkEmpty",
          "typ": 
        }
      ],
      "typ": 
    },
    {
      "kind": "nkEmpty",
      "typ": 
    },
    {
      "kind": "nkEmpty",
      "typ": 
    },
    {
      "kind": "nkStmtList",
      "sons": [
        {
          "kind": "nkCommand",
          "sons": [
            {
              "kind": "nkIdent",
              "ident": "echo",
              "typ": 
            },
            {
              "kind": "nkStrLit",
              "strVal": "test",
              "typ": 
            }
          ],
          "typ": 
        }
      ],
      "typ": 
    }
  ],
  "typ": 
}

POST

{
  "kind": "nkCommand",
  "sons": [
    {
      "kind": "nkIdent",
      "ident": "echo",
      "typ": 
    },
    {
      "kind": "nkStrLit",
      "strVal": "test",
      "typ": 
    }
  ],
  "typ": 
}

Removing the () also causes the StmtListLambda warning to appear so its best to keep it

ire4ever1190 commented 6 months ago

Fixed by #14 :tada: