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

Comments

@alandonovan
Copy link
Contributor

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

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.

@alandonovan
Copy link
Contributor Author

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
Development

No branches or pull requests

3 participants