]> Cypherpunks repositories - gostls13.git/commit
cmd/cover: fix counting of blocks split by goto statements
authorAndrew Gerrand <adg@golang.org>
Fri, 31 May 2019 06:58:44 +0000 (16:58 +1000)
committerAndrew Gerrand <adg@golang.org>
Mon, 3 Jun 2019 01:37:58 +0000 (01:37 +0000)
commit98100c56da0da1503e7612921eff821409aa6cce
tree391e06eb2476bfc0b59e22183c0a6d84f9744716
parentce656af9b5d9acb817b4de5170a11a2c42ad2047
cmd/cover: fix counting of blocks split by goto statements

When adding coverage counters to a block, the block's statement list is
mutated. CL 77150 removed the part where the mutated list is assigned
back to its parent node; this was confusing ast.Walk, which would then
lose its place and stop walking the current block, dropping counters in
the process.

This change has addCounters make a copy of the list before mutating
it, so that the original list doesn't change under Walk's feet.

Fix #32200

Change-Id: Ia3b67d8cee860ceb7caf8748cb7a80ff9c6276e0
Reviewed-on: https://go-review.googlesource.com/c/go/+/179581
Reviewed-by: Rob Pike <r@golang.org>
src/cmd/cover/cover.go
src/cmd/cover/testdata/test.go