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

nimpretty is not aware that the next line is a part of the same context #11469

Closed
narimiran opened this issue Jun 10, 2019 · 0 comments

Comments

@narimiran
Copy link
Member

commented Jun 10, 2019

These are the example from Nim stdlib, when nimpretty is run on them.

Example

proc firstSetBit_nim(x: uint32): int {.inline, nosideeffect.} =
  ## Returns the 1-based index of the least significant set bit of x, or if x is zero, returns zero.
  # https://graphics.stanford.edu/%7Eseander/bithacks.html#ZerosOnRightMultLookup
  const lookup: array[32, uint8] = [0'u8, 1, 28, 2, 29, 14, 24, 3, 30, 22, 20, 15,
    25, 17, 4, 8, 31, 27, 13, 23]


veryLongVariableName.createVar("future" & $node[1][0].toStrLit, node[1], futureValue1,
                               futureValue2, node)


proc longNameGetSystemInfo(info: ptr SystemInfo): int32 {.importc: "get_system_info",
                                                         header: "<OS.h>".}

Current Output

proc firstSetBit_nim(x: uint32): int {.inline, nosideeffect.} =
  ## Returns the 1-based index of the least significant set bit of x, or if x is zero, returns zero.
  # https://graphics.stanford.edu/%7Eseander/bithacks.html#ZerosOnRightMultLookup
  const lookup: array[32, uint8] = [0'u8, 1, 28, 2, 29, 14, 24, 3, 30, 22, 20,
      15,
    25, 17, 4, 8, 31, 27, 13, 23]


veryLongVariableName.createVar("future" & $node[1][0].toStrLit, node[1],
    futureValue1,
                               futureValue2, node)


proc longNameGetSystemInfo(info: ptr SystemInfo): int32 {.
  importc: "get_system_info",
                                                         header: "<OS.h>".}

Expected Output

The indentation of a second line is not important (it doesn't have to be aligned with an open parenthesis/bracket above), the point is to join the lines.

proc firstSetBit_nim(x: uint32): int {.inline, nosideeffect.} =
  ## Returns the 1-based index of the least significant set bit of x, or if x is zero, returns zero.
  # https://graphics.stanford.edu/%7Eseander/bithacks.html#ZerosOnRightMultLookup
  const lookup: array[32, uint8] = [0'u8, 1, 28, 2, 29, 14, 24, 3, 30, 22, 20,
                                    15, 25, 17, 4, 8, 31, 27, 13, 23]


veryLongVariableName.createVar("future" & $node[1][0].toStrLit, node[1],
                               futureValue1, futureValue2, node)


proc longNameGetSystemInfo(info: ptr SystemInfo): int32 {.
  importc: "get_system_info", header: "<OS.h>".}

Additional Information

$ nim -v
Nim Compiler Version 0.20.0 [Linux: amd64]

@narimiran narimiran added the nimpretty label Jun 10, 2019

@Araq Araq closed this in f288e1b Jun 26, 2019

narimiran added a commit that referenced this issue Jun 27, 2019

[bugfix] fix #11469, new rules for a newline in nimpretty (#11512)
* [bugfix] fix #11469, new rules for a newline in nimpretty
* concatenate two lines if they have the same indentation level

(cherry picked from commit f288e1b)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
1 participant
You can’t perform that action at this time.