mirror of
https://github.com/golang/go.git
synced 2025-05-05 15:43:04 +00:00
cmd/compile/internal/walk: fix wrong soleComponent implementation
CL 367755 added soleComponent for handling 1-byte type interface conversion. This implementation must be kept in sync with Type.SoleComponent, but it does not. When seeing a blank field in struct, we must continue looking at the field type to find sole component, if any. The current code just terminate immediately, which causes wrong sole component type returned. Fixes #52020 Change-Id: I4f506fe094fa7c5532de23467a4f9139476bb0a4 Reviewed-on: https://go-review.googlesource.com/c/go/+/396614 Trust: Cuong Manh Le <cuong.manhle.vn@gmail.com> Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Matthew Dempsky <mdempsky@google.com>
This commit is contained in:
parent
f5a42cd4b4
commit
2d34af0fd6
@ -411,7 +411,7 @@ func soleComponent(init *ir.Nodes, n ir.Node) ir.Node {
|
||||
// Treat blank fields as the zero value as the Go language requires.
|
||||
n = typecheck.Temp(n.Type().Field(0).Type)
|
||||
appendWalkStmt(init, ir.NewAssignStmt(base.Pos, n, nil))
|
||||
return n
|
||||
continue
|
||||
}
|
||||
n = typecheck.Expr(ir.NewSelectorExpr(n.Pos(), ir.OXDOT, n, n.Type().Field(0).Sym))
|
||||
case n.Type().IsArray():
|
||||
|
11
test/fixedbugs/issue52020.go
Normal file
11
test/fixedbugs/issue52020.go
Normal file
@ -0,0 +1,11 @@
|
||||
// compile
|
||||
|
||||
// Copyright 2022 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 main
|
||||
|
||||
func main() {
|
||||
var _ interface{} = struct{ _ [1]int8 }{}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user