• Caio Marcelo de Oliveira Filho's avatar
    cmd/cover: don't overskip children nodes when adding counters · e7f6d8b2
    Caio Marcelo de Oliveira Filho authored
    When visiting the AST to add counters, there are special cases in which
    the code calls cuts the walking short by returning nil. In some cases
    certain nodes are ignored, e.g. Init and Cond inside IfStmt.
    
    The fix is to explicitly walk all the children nodes (not only
    Body and Else) when cutting the current walk. Similar approach
    was taken with SwitchStmt and TypeSwitchStmt.
    
    While the existing test code doesn't handle different counters in the
    same line, the generated HTML report does it correctly (because it takes
    column into account).
    
    The previous behavior caused lines in function literals to not be
    tracked when those literals were inside Init or Cond of an IfStmt for
    example.
    
    Fixes #14039.
    
    Change-Id: Iad591363330843ad833bd79a0388d709c8d0c8aa
    Reviewed-on: https://go-review.googlesource.com/19775Reviewed-by: 's avatarRob Pike <r@golang.org>
    e7f6d8b2
Name
Last commit
Last update
..
main.go Loading commit data...
test.go Loading commit data...