cmd/guru: freevars: reenable test of labels (and improve output)

Change-Id: Icb7747d0856a4be2de52e143b793b52a725d297c
Reviewed-on: https://go-review.googlesource.com/19437
Reviewed-by: Alan Donovan <adonovan@google.com>
This commit is contained in:
Alan Donovan 2016-02-11 22:52:19 -05:00 committed by Alan Donovan
parent 37bb37ec1c
commit 789265387f
3 changed files with 10 additions and 4 deletions

View File

@ -184,7 +184,7 @@ func (r *freevarsResult) display(printf printfFunc) {
for _, ref := range r.refs {
// Avoid printing "type T T".
var typstr string
if ref.kind != "type" {
if ref.kind != "type" && ref.kind != "label" {
typstr = " " + types.TypeString(ref.typ, qualifier)
}
printf(ref.obj, "%s %s%s", ref.kind, ref.ref, typstr)

View File

@ -33,9 +33,8 @@ func main() {
f(x) // @freevars fv3 "f.x."
// TODO(adonovan): enable when go/types supports labels.
loop: // #@freevars fv-def-label "loop:"
loop: // @freevars fv-def-label "loop:"
for {
break loop // #@freevars fv-ref-label "break loop"
break loop // @freevars fv-ref-label "break loop"
}
}

View File

@ -16,3 +16,10 @@ var y rune
Free identifiers:
var x int
-------- @freevars fv-def-label --------
No free identifiers.
-------- @freevars fv-ref-label --------
Free identifiers:
label loop