The handling of ONIL and Orig has been a mess for a while, and dates
back to how fmt.go used to print out typed nils. That hasn't applied
for a while, but we've kept dragging it along to appease toolstash
with the intention of someday finally removing it.
Today is that day.
Change-Id: I9a441628e53068ab1993cd2b67b977574d8117b7
Reviewed-on: https://go-review.googlesource.com/c/go/+/274212
Trust: Matthew Dempsky <mdempsky@google.com>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Russ Cox <rsc@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
if !n.Type().HasNil() {
base.Fatalf("unexpected type for nil: %v", n.Type())
}
- if orig := ir.Orig(n); orig != nil && orig != n {
- w.expr(orig)
- break
- }
- w.op(ir.OLITERAL)
+ w.op(ir.ONIL)
w.pos(n.Pos())
w.typ(n.Type())
// case OPAREN:
// unreachable - unpacked by exporter
- // case ONIL:
- // unreachable - mapped to OLITERAL
+ case ir.ONIL:
+ pos := r.pos()
+ typ := r.typ()
+
+ n := npos(pos, nodnil())
+ n.SetType(typ)
+ return n
case ir.OLITERAL:
pos := r.pos()
typ := r.typ()
- var n ir.Node
- if typ.HasNil() {
- n = nodnil()
- } else {
- n = ir.NewLiteral(r.value(typ))
- }
- n = npos(pos, n)
+ n := npos(pos, ir.NewLiteral(r.value(typ)))
n.SetType(typ)
return n