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 changes indentation level of trailing comment #9398

Closed
timotheecour opened this Issue Oct 16, 2018 · 3 comments

Comments

Projects
None yet
3 participants
@timotheecour
Copy link
Collaborator

timotheecour commented Oct 16, 2018

proc fun() =
  echo "ok1"
  # echo "ok2"

fun()

nimpretty wrongly un-indents comment as:

proc fun() =
  echo "ok1"
# echo "ok2"

fun()
@Araq

This comment has been minimized.

Copy link
Member

Araq commented Oct 16, 2018

That's gonna be a tough one.

@timotheecour

This comment has been minimized.

Copy link
Collaborator

timotheecour commented Oct 16, 2018

because regular comments aren't part of AST?

what if we made them part of AST ? (and have a field indicating whether they're doc comment or regular)

there are other use cases, for eg:

  • nimpretty
  • nimfix (which I want to revive at some point, for more general transformations, maybe as separate tool using compiler as library)
  • furthermore, allows user code to reflect on presence of special comments such as #!nimpretty off etc, without extra hacks
@Araq

This comment has been minimized.

Copy link
Member

Araq commented Oct 17, 2018

what if we made them part of AST ?

They were but users complained. ;-) Ok, it also implied that comments could only be inserted in specific parts of the code and it's a messy thing.

Anyway, it's hard to fix because of other reasons. (Or maybe not hard, just annoying.)

@krux02 krux02 changed the title [nimpretty] trailing comment wrongly indented nimpretty changes indentation level of trailing comment Oct 20, 2018

@Araq Araq closed this in e3a0415 Oct 23, 2018

narimiran added a commit to narimiran/Nim that referenced this issue Oct 31, 2018

narimiran added a commit to narimiran/Nim that referenced this issue Nov 1, 2018

narimiran added a commit that referenced this issue Nov 1, 2018

narimiran added a commit that referenced this issue Nov 1, 2018

nimpretty: fixes #9398
(cherry picked from commit e3a0415)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment