1
0
mirror of https://github.com/golang/go synced 2024-11-13 13:40:22 -07:00
go/test/fixedbugs/issue49249.go
Cuong Manh Le 759a9211d4 [release-branch.go1.17] cmd/compile: only update source type when processing struct/array
This is backport of CL 3651594, with the test from CL 360057.

CL 360057 fixed missing update source type in storeArgOrLoad. However,
we should only update the type when processing struct/array. If we
update the type right before calling storeArgOrLoad, we may generate a
value with invalid type, e.g, OpStructSelect with non-struct type.

Fixes #49392

Change-Id: Ib7e10f72f818880f550aae5c9f653db463ce29b0
Reviewed-on: https://go-review.googlesource.com/c/go/+/361594
Trust: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: David Chase <drchase@google.com>
Reviewed-on: https://go-review.googlesource.com/c/go/+/361596
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
2021-12-02 17:52:07 +00:00

56 lines
683 B
Go

// compile -l
// Copyright 2021 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package p
func f() int {
var a, b struct {
s struct {
s struct {
byte
float32
}
}
}
_ = a
return func() int {
return func() int {
a = struct {
s struct {
s struct {
byte
float32
}
}
}{b.s}
return 0
}()
}()
}
func g() int {
var a, b struct {
s [1][1]struct {
byte
float32
}
}
_ = a
return func() int {
return func() int {
a = struct {
s [1][1]struct {
byte
float32
}
}{b.s}
return 0
}()
}()
}