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

cmd/compile: wrong line number in error message #13267

Closed
dvyukov opened this issue Nov 16, 2015 · 2 comments
Closed

cmd/compile: wrong line number in error message #13267

dvyukov opened this issue Nov 16, 2015 · 2 comments
Milestone

Comments

@dvyukov
Copy link
Member

dvyukov commented Nov 16, 2015

newparser/oldparser disagree:

0

$ go tool compile b6589fc6ab0dc82cf12099d1c2d40ab994e8410c
b6589fc6ab0dc82cf12099d1c2d40ab994e8410c:2: syntax error: package statement must be first
$ go tool compile -oldparser b6589fc6ab0dc82cf12099d1c2d40ab994e8410c
b6589fc6ab0dc82cf12099d1c2d40ab994e8410c:1: package statement must be first

go version devel +25a28da Sun Nov 15 23:41:28 2015 +0000 linux/amd64

@dvyukov dvyukov changed the title cmd/compile: wrong line number in error number cmd/compile: wrong line number in error message Nov 16, 2015
@ianlancetaylor ianlancetaylor added this to the Go1.6 milestone Nov 16, 2015
@gopherbot
Copy link

CL https://golang.org/cl/16975 mentions this issue.

@gopherbot
Copy link

CL https://golang.org/cl/19859 mentions this issue.

gopherbot pushed a commit that referenced this issue Feb 24, 2016
After golang.org/cl/19652 removed the bizarre lexlineno{++,--}
statements for parsing canned imports, this hack for #13267 is no
longer necessary:

    $ echo -n 0 > /tmp/0.go
    $ go tool compile /tmp/0.go
    /tmp/0.go:1: syntax error: package statement must be first

Apparently setting lexlineno to 2 while parsing the canned imports
caused prevlineno and lineno to also be set to 2.  After we finished
parsing imports and restored lexlineno to 1, since "package" is the
first token in a source file, we'll have fixed lineno = 1, but
prevlineno was still set to 2.

Change-Id: Ibcc49fe3402264819b9abb53505631f7a0ad4a36
Reviewed-on: https://go-review.googlesource.com/19859
Reviewed-by: Robert Griesemer <gri@golang.org>
@golang golang locked and limited conversation to collaborators Feb 28, 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

4 participants