Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.Sign up
I'm trying to fix and test some issues around cmd/cover and line numbers, but I've run into two compiler problems with the processing of //line directives. These seem like they should be easy fixes.
This creates a trivial x.go with a line directive that gives a full path to a non-existent file in the GOROOT root. (The fact that the file does not exist is irrelevant.)
Then the compiler prints an error because there is no package statement in the file. The error should be reported to the fake file name, and it is, except the path name literally says $GOROOT instead of the actual GOROOT directory.
The $GOROOT appears because that's what we do want to write as the file name in the object file and export data. But for error messages we want to see the actual path name. It looks like objabi.AbsFile is being called incorrectly (a bit too early) while handling the //line directive. It looks like the code needs to distinguish between computing PosBase.filename and PosBase.absFilename, and it makes no such distinction.
Line number stack
For example, the error in the case above needs to say just:
@griesemer I suspect I didn't consider this (obvious in retrospect) case.
CL 63693 also fixes #21720 which I would say is worse than this one, and was backported to 1.9 for it. So I'm disinclined to just revert it without finding a solution to both cases.
I am out today, but can take a look on Monday if you like.
Issues #10043, #15405, and #22660 appear to have been fixed, and whatever tests I could run locally do succeed, so remove the skips. Issue #7237 was closed in favor of #17906, so update its skip line. Issue #7634 was closed as it had not appeared for over three years. Re-enable it for now. An issue should be open if the test starts being skipped again. Change-Id: I67daade906744ed49223291035baddaad9f56dca Reviewed-on: https://go-review.googlesource.com/121735 Run-TryBot: Daniel Martí <email@example.com> TryBot-Result: Gobot Gobot <firstname.lastname@example.org> Reviewed-by: Brad Fitzpatrick <email@example.com>