diff options
author | Dan Scales <danscales@google.com> | 2021-07-13 22:21:54 -0700 |
---|---|---|
committer | Dan Scales <danscales@google.com> | 2021-07-14 21:58:10 +0000 |
commit | e3e6cd30221185d6e4fa76f109f96fdede580729 (patch) | |
tree | 7457c8f438c9633f7a1f29f5c9e84f3d1201ea2a /src/cmd/compile/internal/ir | |
parent | 2b10d7ff0be9ee5ebe1856349714f78936bf059d (diff) | |
download | go-e3e6cd30221185d6e4fa76f109f96fdede580729.tar.gz go-e3e6cd30221185d6e4fa76f109f96fdede580729.zip |
[dev.typeparams] cmd/compile: fix escape printout bugs for -G=3
Call SetPos() in g.expr() so it is available for any new nodes.
Print out the actual type for a composite literal in exprFmt() if
available, else use Ntype if available. Seems generally useful, since
the type name is always more useful than just 'composite literal'.
Fixes a bunch of cases that are excluded in run.go for -G=3.
Change-Id: I40b9bba88027ea4f36d419e3989e7f14891bea04
Reviewed-on: https://go-review.googlesource.com/c/go/+/334609
Trust: Dan Scales <danscales@google.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Diffstat (limited to 'src/cmd/compile/internal/ir')
-rw-r--r-- | src/cmd/compile/internal/ir/fmt.go | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/src/cmd/compile/internal/ir/fmt.go b/src/cmd/compile/internal/ir/fmt.go index 6f6e26dec4..e8dd9df69d 100644 --- a/src/cmd/compile/internal/ir/fmt.go +++ b/src/cmd/compile/internal/ir/fmt.go @@ -714,6 +714,10 @@ func exprFmt(n Node, s fmt.State, prec int) { fmt.Fprintf(s, "... argument") return } + if typ := n.Type(); typ != nil { + fmt.Fprintf(s, "%v{%s}", typ, ellipsisIf(len(n.List) != 0)) + return + } if n.Ntype != nil { fmt.Fprintf(s, "%v{%s}", n.Ntype, ellipsisIf(len(n.List) != 0)) return |