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: implement line directives that allow column information #24143

griesemer opened this issue Feb 27, 2018 · 2 comments

go/parser: implement line directives that allow column information #24143

griesemer opened this issue Feb 27, 2018 · 2 comments


Copy link

@griesemer griesemer commented Feb 27, 2018

This is tracking bug for the go/* library part of #22662: Enable line directives that allow column information.

Copy link

@gopherbot gopherbot commented Feb 28, 2018

Change mentions this issue: go/scanner: recognize //line and /*line directives incl. columns

Copy link

@gopherbot gopherbot commented Mar 9, 2018

Change mentions this issue: go/printer: simplify handling of line directives

gopherbot pushed a commit that referenced this issue Mar 9, 2018
Strangely enough, the existing implementation used adjusted (by line
directives) source positions to determine layout and thus required
position corrections when printing a line directive.

Instead, just use the unadjusted, absolute source positions and then
printing a line directive doesn't require any adjustments, only some
care to make sure it remains in column 1 as before.

The new code doesn't need to parse line directives anymore and simply
ensures that comments with the //line prefix and starting in column 1
remain in that position. That is a slight change from the old behavior
(which ignored incorrect line directives, e.g. because they had an
invalid line number) but unlikely to show up in real code.

This is prep work for handling of line directives that also specify
columns (which now won't require much special handling anymore).

For #24143.

Change-Id: I07eb2e1b35b37337e632e3dbf5b70c783c615f8a
Reviewed-by: Matthew Dempsky <>
@gopherbot gopherbot closed this in 99c3021 Mar 9, 2018
@golang golang locked and limited conversation to collaborators Mar 9, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

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