Skip to content

cmd/cover: inconsistent NumStmt when //line clauses are used with Go 1.13.4 #35781

@jszwedko

Description

@jszwedko

This seems to be the same as #27350 but still happens even after running go fmt which was the recommended fix in that issue (and also in a release that includes d689946 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)?

$ go version
go version go1.13.4 linux/amd64

Does this issue reproduce with the latest release?

Yes

What operating system and processor architecture are you using (go env)?

go env Output
$ go env
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/jesse/.cache/go-build"
GOENV="/home/jesse/.config/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="/home/jesse/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/local/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/linux_amd64"
GCCGO="gccgo"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD="/home/jesse/go/src/github.com/timberio/go-datemath/go.mod"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build279863626=/tmp/go-build -gno-record-gcc-switches"

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    NeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.compiler/runtimeIssues related to the Go compiler and/or runtime.help wanted

    Type

    No type

    Projects

    Status

    Triage Backlog

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions