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 (de)indents code where it shouldn't #11468

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

Comments

@narimiran
Copy link
Member

commented Jun 10, 2019

The difference in the following examples is the indentation of "Deprecated since..." line. The original example is isValid2 and it comes from lib/pure/collections/sets.nim — after nimpretty formats the code, file cannot be run anymore because of Error: invalid indentation.

Notice that while isValid3 still compiles, it gets unneccessarily indented.

Example

proc isValid1*[A](s: HashSet[A]): bool {.deprecated:
  "Deprecated since v0.20; sets are initialized by default".} =
  ## Returns `true` if the set has been initialized (with `initHashSet proc
  ## <#initHashSet,int>`_ or `init proc <#init,HashSet[A],int>`_).
  result = s.data.len > 0

proc isValid2*[A](s: HashSet[A]): bool {.deprecated:
    "Deprecated since v0.20; sets are initialized by default".} =
  ## Returns `true` if the set has been initialized (with `initHashSet proc
  ## <#initHashSet,int>`_ or `init proc <#init,HashSet[A],int>`_).
  result = s.data.len > 0

proc isValid3*[A](s: HashSet[A]): bool {.deprecated:
 "Deprecated since v0.20; sets are initialized by default".} =
  ## Returns `true` if the set has been initialized (with `initHashSet proc
  ## <#initHashSet,int>`_ or `init proc <#init,HashSet[A],int>`_).
  result = s.data.len > 0

Current Output

proc isValid1*[A](s: HashSet[A]): bool {.deprecated:
  "Deprecated since v0.20; sets are initialized by default".} =
  ## Returns `true` if the set has been initialized (with `initHashSet proc
  ## <#initHashSet,int>`_ or `init proc <#init,HashSet[A],int>`_).
  result = s.data.len > 0

proc isValid2*[A](s: HashSet[A]): bool {.deprecated:
  "Deprecated since v0.20; sets are initialized by default".} =
## Returns `true` if the set has been initialized (with `initHashSet proc
  ## <#initHashSet,int>`_ or `init proc <#init,HashSet[A],int>`_).
  result = s.data.len > 0

proc isValid3*[A](s: HashSet[A]): bool {.deprecated:
  "Deprecated since v0.20; sets are initialized by default".} =
    ## Returns `true` if the set has been initialized (with `initHashSet proc
    ## <#initHashSet,int>`_ or `init proc <#init,HashSet[A],int>`_).
    result = s.data.len > 0

Expected Output

proc isValid1*[A](s: HashSet[A]): bool {.deprecated:
  "Deprecated since v0.20; sets are initialized by default".} =
  ## Returns `true` if the set has been initialized (with `initHashSet proc
  ## <#initHashSet,int>`_ or `init proc <#init,HashSet[A],int>`_).
  result = s.data.len > 0

proc isValid2*[A](s: HashSet[A]): bool {.deprecated:
  "Deprecated since v0.20; sets are initialized by default".} =
  ## Returns `true` if the set has been initialized (with `initHashSet proc
  ## <#initHashSet,int>`_ or `init proc <#init,HashSet[A],int>`_).
  result = s.data.len > 0

proc isValid3*[A](s: HashSet[A]): bool {.deprecated:
  "Deprecated since v0.20; sets are initialized by default".} =
  ## Returns `true` if the set has been initialized (with `initHashSet proc
  ## <#initHashSet,int>`_ or `init proc <#init,HashSet[A],int>`_).
  result = s.data.len > 0

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 af39f26 Jun 13, 2019

narimiran added a commit to narimiran/Nim that referenced this issue Jun 16, 2019

[bugfix] nimpretty: fixes nim-lang#11468
(cherry picked from commit af39f26)
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.