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

go/parser: a /* */ file comment immediately preceding package decl is lost #13960

Closed
alandonovan opened this issue Jan 14, 2016 · 2 comments
Closed
Assignees

Comments

@alandonovan
Copy link
Contributor

@alandonovan alandonovan commented Jan 14, 2016

See http://play.golang.org/p/jFoDNNrB9y

I would expect a file that starts with

    /*a*/package main

to have an ast.File.Doc comment of "a", but it has "".

Adding a newline before 'package' causes the File.Doc comment to become "a\n", as it should.

@griesemer
Copy link
Contributor

@griesemer griesemer commented Jan 14, 2016

The comment is not lost as http://play.golang.org/p/Zl0pDK6KIV (click on Format) proves.

This is working as intended. The doc string comes from comments on the immediately preceding lines of a declaration. I don't see any reason to make this any more complicated. It also has worked for several years now w/o anybody complaining.

@griesemer griesemer closed this Jan 14, 2016
@alandonovan
Copy link
Contributor Author

@alandonovan alandonovan commented Jan 14, 2016

Fair enough. My mindset was warped by another (real) bug that I was in the middle of debugging when I found this.

@golang golang locked and limited conversation to collaborators Jan 13, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
3 participants
You can’t perform that action at this time.