Skip to content

error when running tests with coverage in dependant project "cover: inconsistent NumStmt: changed from 1 to 2" #286

@Crocmagnon

Description

@Crocmagnon

When running tests with coverage on a project depending on gojq, I get the following error:

cover: inconsistent NumStmt: changed from 1 to 2

Reproduction with gojq directly:

$ git clone git@github.com:itchyny/gojq.git
Clonage dans 'gojq'...
remote: Enumerating objects: 7971, done.
remote: Counting objects: 100% (1484/1484), done.
remote: Compressing objects: 100% (306/306), done.
remote: Total 7971 (delta 1334), reused 1214 (delta 1174), pack-reused 6487 (from 4)
Réception d'objets: 100% (7971/7971), 1.83 Mio | 4.34 Mio/s, fait.
Résolution des deltas: 100% (5710/5710), fait.

$ cd gojq/

$ go test ./...
go: downloading go1.24.0 (linux/amd64)
go: downloading github.com/mattn/go-runewidth v0.0.15
go: downloading github.com/itchyny/go-yaml v0.0.0-20251001235044-fca9a0999f15
go: downloading github.com/google/go-cmp v0.5.4
ok      github.com/itchyny/gojq 0.736s
ok      github.com/itchyny/gojq/cli     2.880s
?       github.com/itchyny/gojq/cmd/gojq        [no test files]

$ go test -coverprofile=cover.profile ./...
ok      github.com/itchyny/gojq 0.671s  coverage: 52.6% of statements
ok      github.com/itchyny/gojq/cli     3.056s  coverage: 92.0% of statements
        github.com/itchyny/gojq/cmd/gojq                coverage: 0.0% of statements

$ go tool cover -html cover.profile
cover: inconsistent NumStmt: changed from 1 to 2

I found golang/go#45361, apparently there's an issue with goyacc and a workaround.
Would it be possible to release a new version of gojq with the workaround implemented?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions