-
Notifications
You must be signed in to change notification settings - Fork 17.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
cmd/go: omit non-executable "func _()" functions from coverage profiles #36264
Comments
I get the feeling that this missed getting put into the Proposals project. Maybe I shouldn't have made it a proposal at all. |
This doesn't really need to be a proposal. If you'd like to send a fix, the tree is open now. 🙂 |
Thanks, that's what I figured. I'm still not sure what should and shouldn't be a proposal... 😄 I'll take a look, though I'm definitely not familiar with this particular code. |
Change https://golang.org/cl/223117 mentions this issue: |
My CL was merged during the Go 1.15 cycle; you should see it fixed in an RC or on gotip. It wouldn't be fixed in Go 1.14. |
Oh. Ok, thanks for the quick reply! |
Currently, coverage profiles include coverage for functions that cannot ever run (
func _() { ... }
). These sorts of functions are commonly used to generate compile-time checks that aren't expected to actually execute. For example, code generated bystringer
:Could have a coverage profile of:
Note the first line, which says
7.10,17.2 7 0
, i.e. the_
function has zero lines covered.I propose that coverage data should be omitted for these
_
functions. My rationale:go test
itself.I'm not sure if this is a proper "proposal", but I didn't think it was exactly a "bug" either. Feel free to retitle as needed.
The text was updated successfully, but these errors were encountered: