I'm using Ragel to generate a lexer. Ragel includes //line clauses in
the generated code which help the Go compiler point back to the original .rl
file when compilation fails.
If I run ragel to generate the code and try to profile the coverage of the
generated code, the go tool cover command fails with the error, inconsistent NumStmt: changed from 2 to 3.
$ brew install ragel
$ ragel --version
Ragel State Machine Compiler version 6.10 March 2017
Copyright (c) 2001-2009 by Adrian Thurston
$ ragel -Z -G2 -o lex.go lex.rl
$ go test -covermode=count -coverprofile cover.out -coverpkg=. .
ok cover-repro 0.006s coverage: 0.0% of statements in.
$ go tool cover -html=cover.out -o cover.html
cover: inconsistent NumStmt: changed from 2 to 3
This has not been an issue in Go 1.5-1.10.
Here's a minimal (non-sensical) lexer for which I was able to reproduce this
* *: added support for storing checkpoint at local filesystem
* config, tests: change default checkpoint driver to "file"
* mydump: regenerate the parser to avoid golang/go#27350 during coverage
* checkpoints: addressed comments