cmd/cover: inconsistent NumStmt when //line clauses are used with Go 1.13.4
#35,781 opened on Nov 22, 2019
Repository metrics
- Stars
- (133,883 stars)
- PR merge metrics
- (No merged PRs in 30d)
Description
This seems to be the same as https://github.com/golang/go/issues/27350 but still happens even after running go fmt which was the recommended fix in that issue (and also in a release that includes https://github.com/golang/go/commit/d6899463029d8ab0d73c992ccf6639f095435b84 which was intended to mitigate it).
Removing all //line comments from the file allows it to pass.
What version of Go are you using (go version)?
Does this issue reproduce with the latest release?
Yes
What operating system and processor architecture are you using (go env)?
What did you do?
Using this repo, which uses goyacc to generate datemath.y.go, https://github.com/timberio/go-datemath
$ go test -coverprofile=c.out && go tool cover -html=c.out
PASS
coverage: 71.4% of statements
ok github.com/timberio/go-datemath 0.003s
cover: inconsistent NumStmt: changed from 2 to 1
I see the same issue using the example in the goyacc directory:
https://github.com/golang/tools/tree/master/cmd/goyacc/testdata/expr
When adding a dummy test file:
$ cat expr_test.go
package main
import "testing"
func TestFoo(t *testing.T) {
}
and then running:
$ go generate && go fmt && go test -coverprofile=c.out && go tool cover -html=c.out
PASS
coverage: 0.0% of statements
ok golang.org/x/tools/cmd/goyacc/testdata/expr 0.003s
cover: inconsistent NumStmt: changed from 1 to 2
What did you expect to see?
The coverage pulled up in the browser.
What did you see instead?
PASS
coverage: 71.4% of statements
ok github.com/timberio/go-datemath 0.006s
cover: inconsistent NumStmt: changed from 2 to 1