From: Matthew Dempsky Date: Wed, 25 Sep 2019 06:56:50 +0000 (-0700) Subject: cmd/compile: use underlying OCOMPLIT's position for OPTRLIT X-Git-Tag: go1.14beta1~983 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=efb9739203fc0b66f5593c5edbe0bc0fd6062956;p=gostls13.git cmd/compile: use underlying OCOMPLIT's position for OPTRLIT Currently, when we create an OPTRLIT node, it defaults to the OCOMPLIT's final element's position. But it improves error messages to use the OCOMPLIT's own position instead. Change-Id: Ibb031f543c7248d88d99fd0737685e01d86e2500 Reviewed-on: https://go-review.googlesource.com/c/go/+/197119 Run-TryBot: Matthew Dempsky TryBot-Result: Gobot Gobot Reviewed-by: Brad Fitzpatrick --- diff --git a/src/cmd/compile/internal/gc/typecheck.go b/src/cmd/compile/internal/gc/typecheck.go index b35ab543ec..580e9154e1 100644 --- a/src/cmd/compile/internal/gc/typecheck.go +++ b/src/cmd/compile/internal/gc/typecheck.go @@ -3026,7 +3026,7 @@ func typecheckcomplit(n *Node) (res *Node) { n.Orig = norig if n.Type.IsPtr() { - n = nod(OPTRLIT, n, nil) + n = nodl(n.Pos, OPTRLIT, n, nil) n.SetTypecheck(1) n.Type = n.Left.Type n.Left.Type = t diff --git a/test/escape_iface.go b/test/escape_iface.go index 898f504b31..118ed3c56f 100644 --- a/test/escape_iface.go +++ b/test/escape_iface.go @@ -220,8 +220,8 @@ type T2 struct { func dotTypeEscape() *T2 { // #11931 var x interface{} x = &T1{p: new(int)} // ERROR "new\(int\) escapes to heap" "&T1 literal does not escape" - return &T2{ - T1: *(x.(*T1)), // ERROR "&T2 literal escapes to heap" + return &T2{ // ERROR "&T2 literal escapes to heap" + T1: *(x.(*T1)), } }