Update to go1.24.0
This commit is contained in:
16
test/fixedbugs/issue68526.dir/a/a.go
Normal file
16
test/fixedbugs/issue68526.dir/a/a.go
Normal file
@@ -0,0 +1,16 @@
|
||||
// Copyright 2024 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.
|
||||
|
||||
//go:build goexperiment.aliastypeparams
|
||||
|
||||
package a
|
||||
|
||||
type A[T any] = struct{ F T }
|
||||
|
||||
type B = struct{ F int }
|
||||
|
||||
func F() B {
|
||||
type a[T any] = struct{ F T }
|
||||
return a[int]{}
|
||||
}
|
||||
45
test/fixedbugs/issue68526.dir/main.go
Normal file
45
test/fixedbugs/issue68526.dir/main.go
Normal file
@@ -0,0 +1,45 @@
|
||||
// Copyright 2024 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.
|
||||
|
||||
//go:build goexperiment.aliastypeparams
|
||||
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"issue68526.dir/a"
|
||||
)
|
||||
|
||||
func main() {
|
||||
unexported()
|
||||
exported()
|
||||
}
|
||||
|
||||
func unexported() {
|
||||
var want struct{ F int }
|
||||
|
||||
if any(want) != any(a.B{}) || any(want) != any(a.F()) {
|
||||
panic("zero value of alias and concrete type not identical")
|
||||
}
|
||||
}
|
||||
|
||||
func exported() {
|
||||
var (
|
||||
astr a.A[string]
|
||||
aint a.A[int]
|
||||
)
|
||||
|
||||
if any(astr) != any(struct{ F string }{}) || any(aint) != any(struct{ F int }{}) {
|
||||
panic("zero value of alias and concrete type not identical")
|
||||
}
|
||||
|
||||
if any(astr) == any(aint) {
|
||||
panic("zero value of struct{ F string } and struct{ F int } are not distinct")
|
||||
}
|
||||
|
||||
if got := fmt.Sprintf("%T", astr); got != "struct { F string }" {
|
||||
panic(got)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user