aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/compile/testdata/script
diff options
context:
space:
mode:
authorCuong Manh Le <cuong.manhle.vn@gmail.com>2025-09-15 17:31:46 +0700
committerGopher Robot <gobot@golang.org>2025-09-23 11:43:48 -0700
commita5866ebe40207c4c64f0522721825b10887356e0 (patch)
treef22e7f664af062ea00b4ffae14fe51664489760e /src/cmd/compile/testdata/script
parenta27261c42fcebf601587725714b9ef53c47b06b3 (diff)
downloadgo-a5866ebe40207c4c64f0522721825b10887356e0.tar.xz
cmd/compile: prevent shapifying of pointer shape type
CL 641955 changes the Unified IR reader to not doing shapify when reading reshaping expression, prevent losing of the original type. This is an oversight, as the main problem isn't about shaping during the reshaping process itself, but about the specific case of shaping a pointer shape type. This bug occurs when instantiating a generic function within another generic function with a pointer shape type as type parameter, which will convert `*[]go.shape.T` to `*go.shape.uint8`, resulting in the loss of the original expression's type. This commit changes Unified IR reader to avoid pointer shaping for `*[]go.shape.T`, ensures that the original type is preserved when processing reshaping expressions. Updates #71184 Updates #73947 Fixes #74260 Fixes #75461 Change-Id: Icede6b73247d0d367bb485619f2dafb60ad66806 Reviewed-on: https://go-review.googlesource.com/c/go/+/704095 Auto-Submit: Cuong Manh Le <cuong.manhle.vn@gmail.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: David Chase <drchase@google.com> Reviewed-by: Junyang Shao <shaojunyang@google.com>
Diffstat (limited to 'src/cmd/compile/testdata/script')
-rw-r--r--src/cmd/compile/testdata/script/issue75461.txt78
1 files changed, 78 insertions, 0 deletions
diff --git a/src/cmd/compile/testdata/script/issue75461.txt b/src/cmd/compile/testdata/script/issue75461.txt
new file mode 100644
index 0000000000..05f0fd4cfa
--- /dev/null
+++ b/src/cmd/compile/testdata/script/issue75461.txt
@@ -0,0 +1,78 @@
+go build main.go
+! stdout .
+! stderr .
+
+-- main.go --
+package main
+
+import (
+ "demo/registry"
+)
+
+func main() {
+ _ = registry.NewUserRegistry()
+}
+
+-- go.mod --
+module demo
+
+go 1.24
+
+-- model/user.go --
+package model
+
+type User struct {
+ ID int
+}
+
+func (c *User) String() string {
+ return ""
+}
+
+-- ordered/map.go --
+package ordered
+
+type OrderedMap[K comparable, V any] struct {
+ m map[K]V
+}
+
+func New[K comparable, V any](options ...any) *OrderedMap[K, V] {
+ orderedMap := &OrderedMap[K, V]{}
+ return orderedMap
+}
+
+-- registry/user.go --
+package registry
+
+import (
+ "demo/model"
+ "demo/ordered"
+)
+
+type baseRegistry = Registry[model.User, *model.User]
+
+type UserRegistry struct {
+ *baseRegistry
+}
+
+type Registry[T any, P PStringer[T]] struct {
+ m *ordered.OrderedMap[string, P]
+}
+
+type PStringer[T any] interface {
+ *T
+ String() string
+}
+
+func NewRegistry[T any, P PStringer[T]]() *Registry[T, P] {
+ r := &Registry[T, P]{
+ m: ordered.New[string, P](),
+ }
+ return r
+}
+
+func NewUserRegistry() *UserRegistry {
+ return &UserRegistry{
+ baseRegistry: NewRegistry[model.User](),
+ }
+}