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

x/tools/go/types: line number out of range #11329

Closed
dvyukov opened this issue Jun 22, 2015 · 4 comments
Closed

x/tools/go/types: line number out of range #11329

dvyukov opened this issue Jun 22, 2015 · 4 comments

Comments

@dvyukov
Copy link
Member

dvyukov commented Jun 22, 2015

Gc rejects to compile the following program:

package a //line :1000000000

saying:

line number out of range

gotype compiles it successfully.

Compilers should agree on whether it is a valid Go program or not.

on commit af81789

@griesemer
Copy link
Contributor

The spec doesn't mention the interpretation of //line comments - this is a tool (compiler)-specific feature. I think there are 2 issues here:

  1. The compiler should probably ignore //line comments that don't start at the beginning of the line.
  2. The compiler should do something sensible when the //line comment is incorrect (as in this case).

FWIW, go/types simply ignores incorrect //line comments or //line comments with out-of-range (64bit int) line numbers.

Leaving to rsc.

@griesemer griesemer added this to the Unplanned milestone Jun 22, 2015
@griesemer griesemer assigned rsc and unassigned griesemer Jun 22, 2015
@dvyukov
Copy link
Member Author

dvyukov commented Jun 23, 2015

I understand that this is implementation-specific, but there seems to be no point in having different behavior in different compilers here. This makes side-by-side comparison of compilers difficult.

@griesemer
Copy link
Contributor

I believe cmd/compile (gc) should accept this program. The //line comment doesn't start on the beginning of a line and should be ignored. Making this a gc bug.

@ALTree
Copy link
Member

ALTree commented Feb 15, 2017

Fixed in go1.8 by d390283.

@ALTree ALTree closed this as completed Feb 15, 2017
@golang golang locked and limited conversation to collaborators Feb 15, 2018
@rsc rsc removed their assignment Jun 23, 2022
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

5 participants