mirror of
https://github.com/golang/go
synced 2024-11-18 18:04:46 -07:00
cmd/compile/internal/ir: simplify formatting of CompLitExpr
Composite literals always have a type now, so the extra fallback code isn't necessary. But also, to prepare for the upcoming removal of OrigNode, we need to print OSLICELIT with Implicit set as "... argument" to satisfy existing regress tests. Change-Id: I365e879066903eebf1b78e10c1b505565cea3ce3 Reviewed-on: https://go-review.googlesource.com/c/go/+/526396 Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Auto-Submit: Matthew Dempsky <mdempsky@google.com> Reviewed-by: Keith Randall <khr@google.com> Reviewed-by: Keith Randall <khr@golang.org>
This commit is contained in:
parent
7f1f4a1936
commit
0a49d4a778
@ -639,33 +639,17 @@ func exprFmt(n Node, s fmt.State, prec int) {
|
||||
}
|
||||
fmt.Fprintf(s, "%v { %v }", n.Type(), n.Func.Body)
|
||||
|
||||
case OCOMPLIT:
|
||||
n := n.(*CompLitExpr)
|
||||
if !exportFormat {
|
||||
if n.Implicit() {
|
||||
fmt.Fprintf(s, "... argument")
|
||||
return
|
||||
}
|
||||
if typ := n.Type(); typ != nil {
|
||||
fmt.Fprintf(s, "%v{%s}", typ, ellipsisIf(len(n.List) != 0))
|
||||
return
|
||||
}
|
||||
fmt.Fprint(s, "composite literal")
|
||||
return
|
||||
}
|
||||
fmt.Fprintf(s, "(%v{ %.v })", n.Type(), n.List)
|
||||
|
||||
case OPTRLIT:
|
||||
n := n.(*AddrExpr)
|
||||
fmt.Fprintf(s, "&%v", n.X)
|
||||
|
||||
case OSTRUCTLIT, OARRAYLIT, OSLICELIT, OMAPLIT:
|
||||
case OCOMPLIT, OSTRUCTLIT, OARRAYLIT, OSLICELIT, OMAPLIT:
|
||||
n := n.(*CompLitExpr)
|
||||
if !exportFormat {
|
||||
fmt.Fprintf(s, "%v{%s}", n.Type(), ellipsisIf(len(n.List) != 0))
|
||||
if n.Implicit() {
|
||||
fmt.Fprintf(s, "... argument")
|
||||
return
|
||||
}
|
||||
fmt.Fprintf(s, "(%v{ %.v })", n.Type(), n.List)
|
||||
fmt.Fprintf(s, "%v{%s}", n.Type(), ellipsisIf(len(n.List) != 0))
|
||||
|
||||
case OKEY:
|
||||
n := n.(*KeyExpr)
|
||||
|
Loading…
Reference in New Issue
Block a user