nim-lang / Nim

Nim is a statically typed compiled systems programming language. It combines successful concepts from mature languages like Python, Ada and Modula. Its design focuses on efficiency, expressiveness, and elegance (in that order of priority).
https://nim-lang.org
Other
16.63k stars 1.47k forks source link

Nimpretty breaks with multi-line lambda procedures #21018

Open vishnumad opened 1 year ago

vishnumad commented 1 year ago

Description

With the following code, every run of nimpretty causes lines 4-8 get indented further and further.

import std/[strutils, sequtils]

let input = "foo,bar,baz"
  .split(',')
  .map(
    proc (n: string): bool =
      return true
  )

Output after run 1:

let input = "foo,bar,baz"
      .split(',')
      .map(
        proc (n: string): bool =
            return true
      )

Output after run 2:

let input = "foo,bar,baz"
            .split(',')
            .map(
              proc (n: string): bool =
                        return true
            )

Output after run 3:

let input = "foo,bar,baz"
                        .split(',')
                        .map(
                          proc (n: string): bool =
                                                return true
                        )

Nim Version

Nim Compiler Version 1.6.10 [Linux: amd64] Compiled at 2022-11-21 Copyright (c) 2006-2021 by Andreas Rumpf

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

Current Output

No response

Expected Output

let input = "foo,bar,baz"
  .split(',')
  .map(
    proc (n: string): bool =
      return true
  )

Possible Solution

No response

Additional Information

No response

momeemt commented 1 year ago

May I work on it?

ringabout commented 1 year ago

It would be appreciated, go for it!

ringabout commented 1 year ago

You may check compiler/layouter.nim and nimpretty defines.