Skip to content

Commit f121e0e

Browse files
committed
cmd/compile: fix nodedump output for types of nodes
The Dbg dumping of complex types was broken, because (I think) of a recent change to handle recursive types correctly. Before this fix, the Dump output of a closure node (where the last thing on the line is the type of the node) was: . . CLOSURE l(8) esc(h) tc(1) FUNC-@0 after this change it is: . . CLOSURE l(8) esc(h) tc(1) FUNC-func(int) int The problem is that that the 'mode == Fdbg' code was immediately aborting the descent into tconv2, since it was calling down with the same node that was just entered into the hash table. Change-Id: Iee106b967cea1856dd92d4350681401dd34a23b3 Reviewed-on: https://go-review.googlesource.com/c/go/+/264025 Trust: Dan Scales <[email protected]> Reviewed-by: Keith Randall <[email protected]>
1 parent 3ca3ca5 commit f121e0e

File tree

1 file changed

+7
-6
lines changed
  • src/cmd/compile/internal/gc

1 file changed

+7
-6
lines changed

src/cmd/compile/internal/gc/fmt.go

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -792,6 +792,13 @@ func tconv2(b *bytes.Buffer, t *types.Type, flag FmtFlag, mode fmtMode, visited
792792
return
793793
}
794794

795+
if mode == FDbg {
796+
b.WriteString(t.Etype.String())
797+
b.WriteByte('-')
798+
tconv2(b, t, flag, FErr, visited)
799+
return
800+
}
801+
795802
// At this point, we might call tconv2 recursively. Add the current type to the visited list so we don't
796803
// try to print it recursively.
797804
// We record the offset in the result buffer where the type's text starts. This offset serves as a reference
@@ -805,12 +812,6 @@ func tconv2(b *bytes.Buffer, t *types.Type, flag FmtFlag, mode fmtMode, visited
805812
visited[t] = b.Len()
806813
defer delete(visited, t)
807814

808-
if mode == FDbg {
809-
b.WriteString(t.Etype.String())
810-
b.WriteByte('-')
811-
tconv2(b, t, flag, FErr, visited)
812-
return
813-
}
814815
switch t.Etype {
815816
case TPTR:
816817
b.WriteByte('*')

0 commit comments

Comments
 (0)