]> Cypherpunks repositories - gostls13.git/commit
cmd/compile: fix recognition of unnamed return variables
authorMatthew Dempsky <mdempsky@google.com>
Fri, 30 Oct 2020 19:58:28 +0000 (12:58 -0700)
committerMatthew Dempsky <mdempsky@google.com>
Sun, 1 Nov 2020 01:06:56 +0000 (01:06 +0000)
commit063a91c0abef445154df1ba34ffb500eeccfe8bc
tree96be33fdceba41bed0a6a1efb0c09848decf17f4
parent715d4e2e014fa54f527ee109f26a31f941196381
cmd/compile: fix recognition of unnamed return variables

In golang.org/cl/266199, I reused the existing code in inlining that
recognizes anonymous variables. However, it turns out that code
mistakenly recognizes anonymous return parameters as named when
inlining a function from the same package.

The issue is funcargs (which is only used for functions parsed from
source) synthesizes ~r names for anonymous return parameters, but
funcargs2 (which is only used for functions imported from export data)
does not.

This CL fixes the behavior so that anonymous return parameters are
handled identically whether a function is inlined within the same
package or across packages. It also adds a proper cross-package test
case demonstrating #33160 is fixed in both cases.

Change-Id: Iaa39a23f5666979a1f5ca6d09fc8c398e55b784c
Reviewed-on: https://go-review.googlesource.com/c/go/+/266719
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: David Chase <drchase@google.com>
Trust: Matthew Dempsky <mdempsky@google.com>
src/cmd/compile/internal/gc/inl.go
src/cmd/compile/internal/logopt/logopt_test.go
test/fixedbugs/issue42284.dir/a.go
test/fixedbugs/issue42284.dir/b.go