fix spurious indent and newlines in rendering of nkRecList (#23121)

Rendering of `nkRecList` produces an indent and adds a new line at the
end. However for things like case object `of`/`else` branches or `when`
branches this is already done, so this produces 2 indents and an extra
new line. Instead, just add an indent in the place where the indent that
`nkRecList` produces is needed, for the rendering of the final node of
`nkObjectTy`. There doesn't seem to be a need to add the newline.

Before:

```nim
case x*: bool
of true:
    y*: int

of false:
  nil
```

After:

```nim
case x*: bool
of true:
  y*: int
of false:
  nil
```

(cherry picked from commit fc49c6e3ba)
This commit is contained in:
metagn
2023-12-24 17:22:10 +03:00
committed by narimiran
parent 8efdc313a3
commit f8d538f4ad
5 changed files with 10 additions and 20 deletions

View File

@@ -347,8 +347,7 @@ proc getTypeImpl*(n: NimNode): NimNode {.magic: "NGetType", noSideEffect.} =
newLit(x.getTypeImpl.repr)
let t = """
object
arr: array[0 .. 3, float32]
"""
arr: array[0 .. 3, float32]"""
doAssert(dumpTypeImpl(a) == t)
doAssert(dumpTypeImpl(b) == t)
doAssert(dumpTypeImpl(c) == t)