Update to go1.25.0
This commit is contained in:
@@ -9,7 +9,7 @@ package main
|
||||
func putint(digits *string) {
|
||||
var i byte;
|
||||
i = (*digits)[7]; // compiles
|
||||
i = digits[7]; // ERROR "illegal|is not|invalid"
|
||||
i = digits[7]; // ERROR "illegal|is not|cannot index"
|
||||
_ = i;
|
||||
}
|
||||
|
||||
|
||||
@@ -17,14 +17,14 @@ func FooN(vals ...*int) (s int) { // ERROR "vals does not escape"
|
||||
|
||||
// Append forces heap allocation and copies entries in vals to heap, therefore they escape to heap.
|
||||
func FooNx(x *int, vals ...*int) (s int) { // ERROR "leaking param: x" "leaking param content: vals"
|
||||
vals = append(vals, x)
|
||||
vals = append(vals, x) // ERROR "append does not escape"
|
||||
return FooN(vals...)
|
||||
}
|
||||
|
||||
var sink []*int
|
||||
|
||||
func FooNy(x *int, vals ...*int) (s int) { // ERROR "leaking param: x" "leaking param: vals"
|
||||
vals = append(vals, x)
|
||||
vals = append(vals, x) // ERROR "append escapes to heap"
|
||||
sink = vals
|
||||
return FooN(vals...)
|
||||
}
|
||||
@@ -84,7 +84,7 @@ func TFooI() {
|
||||
a := int32(1) // ERROR "moved to heap: a"
|
||||
b := "cat"
|
||||
c := &a
|
||||
FooI(a, b, c) // ERROR "a escapes to heap" "b escapes to heap" "... argument does not escape"
|
||||
FooI(a, b, c) // ERROR "a escapes to heap" ".cat. escapes to heap" "... argument does not escape"
|
||||
}
|
||||
|
||||
func FooJ(args ...interface{}) *int32 { // ERROR "leaking param: args to result ~r0 level=1"
|
||||
@@ -108,14 +108,14 @@ func TFooJ1() {
|
||||
a := int32(1)
|
||||
b := "cat"
|
||||
c := &a
|
||||
FooJ(a, b, c) // ERROR "a does not escape" "b does not escape" "... argument does not escape"
|
||||
FooJ(a, b, c) // ERROR "a does not escape" ".cat. does not escape" "... argument does not escape"
|
||||
}
|
||||
|
||||
func TFooJ2() {
|
||||
a := int32(1) // ERROR "moved to heap: a"
|
||||
b := "cat"
|
||||
c := &a
|
||||
isink = FooJ(a, b, c) // ERROR "a escapes to heap" "b escapes to heap" "... argument does not escape"
|
||||
isink = FooJ(a, b, c) // ERROR "a escapes to heap" ".cat. escapes to heap" "... argument does not escape"
|
||||
}
|
||||
|
||||
type fakeSlice struct {
|
||||
@@ -144,7 +144,7 @@ func TFooK2() {
|
||||
a := int32(1) // ERROR "moved to heap: a"
|
||||
b := "cat"
|
||||
c := &a
|
||||
fs := fakeSlice{3, &[4]interface{}{a, b, c, nil}} // ERROR "a escapes to heap" "b escapes to heap" "&\[4\]interface {}{...} does not escape"
|
||||
fs := fakeSlice{3, &[4]interface{}{a, b, c, nil}} // ERROR "a escapes to heap" ".cat. escapes to heap" "&\[4\]interface {}{...} does not escape"
|
||||
isink = FooK(fs)
|
||||
}
|
||||
|
||||
@@ -169,6 +169,6 @@ func TFooL2() {
|
||||
a := int32(1) // ERROR "moved to heap: a"
|
||||
b := "cat"
|
||||
c := &a
|
||||
s := []interface{}{a, b, c} // ERROR "a escapes to heap" "b escapes to heap" "\[\]interface {}{...} does not escape"
|
||||
s := []interface{}{a, b, c} // ERROR "a escapes to heap" ".cat. escapes to heap" "\[\]interface {}{...} does not escape"
|
||||
isink = FooL(s)
|
||||
}
|
||||
|
||||
@@ -51,7 +51,7 @@ func test1(iter int) {
|
||||
// var fn func() // this makes it work, because fn stays off heap
|
||||
j := 0 // ERROR "moved to heap: j$"
|
||||
fn = func() { // ERROR "func literal escapes to heap$"
|
||||
m[i] = append(m[i], 0)
|
||||
m[i] = append(m[i], 0) // ERROR "append escapes to heap"
|
||||
if j < 25 {
|
||||
j++
|
||||
fn()
|
||||
@@ -75,7 +75,7 @@ func test2(iter int) {
|
||||
var fn func() // this makes it work, because fn stays off heap
|
||||
j := 0
|
||||
fn = func() { // ERROR "func literal does not escape$"
|
||||
m[i] = append(m[i], 0)
|
||||
m[i] = append(m[i], 0) // ERROR "append escapes to heap"
|
||||
if j < 25 {
|
||||
j++
|
||||
fn()
|
||||
|
||||
@@ -6,4 +6,4 @@
|
||||
|
||||
package main
|
||||
|
||||
const A = complex(0()) // ERROR "cannot call non-function"
|
||||
const A = complex(0()) // ERROR "cannot call .* not a function"
|
||||
|
||||
@@ -13,7 +13,7 @@ func F() {
|
||||
slice := []int{1, 2, 3}
|
||||
_ = slice
|
||||
len := int(2)
|
||||
println(len(slice)) // ERROR "cannot call non-function len .type int., declared at LINE-1|expected function|cannot call non-function len"
|
||||
println(len(slice)) // ERROR "cannot call non-function len .type int., declared at LINE-1|expected function|cannot call len"
|
||||
const iota = 1
|
||||
println(iota(slice)) // ERROR "cannot call non-function iota .type int., declared at LINE-1|expected function|cannot call non-function iota"
|
||||
println(iota(slice)) // ERROR "cannot call non-function iota .type int., declared at LINE-1|expected function|cannot call iota"
|
||||
}
|
||||
|
||||
@@ -11,9 +11,9 @@ package p
|
||||
var a = []int{1,2,3}
|
||||
|
||||
func _(len int) {
|
||||
_ = len(a) // ERROR "cannot call non-function|expected function"
|
||||
_ = len(a) // ERROR "cannot call|expected function"
|
||||
}
|
||||
|
||||
var cap = false
|
||||
var _ = cap(a) // ERROR "cannot call non-function|expected function"
|
||||
var _ = cap(a) // ERROR "cannot call|expected function"
|
||||
|
||||
|
||||
@@ -15,5 +15,5 @@ func debugf(format string, args ...interface{}) { // ERROR "can inline debugf" "
|
||||
|
||||
func bar() { // ERROR "can inline bar"
|
||||
value := 10
|
||||
debugf("value is %d", value) // ERROR "inlining call to debugf" "value does not escape" "\.\.\. argument does not escape"
|
||||
debugf("value is %d", value) // ERROR "inlining call to debugf" "10 does not escape" "\.\.\. argument does not escape"
|
||||
}
|
||||
|
||||
@@ -4,6 +4,6 @@
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
//go:build !nacl && !js
|
||||
//go:build !nacl && !js && !wasip1
|
||||
|
||||
package ignored
|
||||
|
||||
@@ -6,4 +6,4 @@
|
||||
|
||||
package p
|
||||
|
||||
func init() // ERROR "missing function body|cannot declare init"
|
||||
func init() // ERROR "func init must have a body|cannot declare init"
|
||||
|
||||
@@ -12,6 +12,6 @@ func f() { // ERROR ""
|
||||
_ = make([]byte, 100, 1<<17) // ERROR "too large for stack" ""
|
||||
_ = make([]byte, n, 1<<17) // ERROR "too large for stack" ""
|
||||
|
||||
_ = make([]byte, n) // ERROR "non-constant size" ""
|
||||
_ = make([]byte, 100, m) // ERROR "non-constant size" ""
|
||||
_ = make([]byte, n) // ERROR "does not escape"
|
||||
_ = make([]byte, 100, m) // ERROR "does not escape"
|
||||
}
|
||||
|
||||
17
test/fixedbugs/issue71184.go
Normal file
17
test/fixedbugs/issue71184.go
Normal file
@@ -0,0 +1,17 @@
|
||||
// compile
|
||||
|
||||
// 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.
|
||||
|
||||
package x
|
||||
|
||||
func F[T int32]() {
|
||||
_ = G[*[0]T]()[:]
|
||||
}
|
||||
|
||||
func G[T any]() (v T) {
|
||||
return
|
||||
}
|
||||
|
||||
var _ = F[int32]
|
||||
19
test/fixedbugs/issue71225.go
Normal file
19
test/fixedbugs/issue71225.go
Normal file
@@ -0,0 +1,19 @@
|
||||
// build
|
||||
|
||||
//go:build cgo
|
||||
|
||||
// Copyright 2025 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
|
||||
|
||||
// #cgo CFLAGS: -Werror -Wunused-parameter
|
||||
import "C"
|
||||
|
||||
func main() {
|
||||
}
|
||||
|
||||
//export Fn
|
||||
func Fn() {
|
||||
}
|
||||
29
test/fixedbugs/issue71226.go
Normal file
29
test/fixedbugs/issue71226.go
Normal file
@@ -0,0 +1,29 @@
|
||||
// build
|
||||
|
||||
//go:build cgo
|
||||
|
||||
// Copyright 2025 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
|
||||
|
||||
/*
|
||||
#cgo CFLAGS: -Werror -Wimplicit-function-declaration
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
static void CFn(_GoString_ gostr) {
|
||||
printf("%.*s\n", (int)(_GoStringLen(gostr)), _GoStringPtr(gostr));
|
||||
}
|
||||
*/
|
||||
import "C"
|
||||
|
||||
func main() {
|
||||
C.CFn("hello, world")
|
||||
}
|
||||
|
||||
// The bug only occurs if there is an exported function.
|
||||
//export Fn
|
||||
func Fn() {
|
||||
}
|
||||
20
test/fixedbugs/issue71759.go
Normal file
20
test/fixedbugs/issue71759.go
Normal file
@@ -0,0 +1,20 @@
|
||||
// run
|
||||
|
||||
// Copyright 2025 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
|
||||
|
||||
//go:noinline
|
||||
func f(p *[2]int32) (int64, int64) {
|
||||
return int64(p[0]), int64(p[1])
|
||||
}
|
||||
|
||||
func main() {
|
||||
p := [2]int32{-1, -1}
|
||||
x, y := f(&p)
|
||||
if x != -1 || y != -1 {
|
||||
println(x, y)
|
||||
}
|
||||
}
|
||||
70
test/fixedbugs/issue72844.go
Normal file
70
test/fixedbugs/issue72844.go
Normal file
@@ -0,0 +1,70 @@
|
||||
// run
|
||||
|
||||
// Copyright 2025 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
|
||||
|
||||
//go:noinline
|
||||
func nilPtrFunc() *[4]int {
|
||||
return nil
|
||||
}
|
||||
|
||||
var nilPtrVar *[4]int
|
||||
|
||||
func testLen1() {
|
||||
_ = len(*nilPtrFunc())
|
||||
}
|
||||
|
||||
func testLen2() {
|
||||
_ = len(nilPtrFunc())
|
||||
}
|
||||
|
||||
func testLen3() {
|
||||
_ = len(*nilPtrVar)
|
||||
}
|
||||
|
||||
func testLen4() {
|
||||
_ = len(nilPtrVar)
|
||||
}
|
||||
|
||||
func testRange1() {
|
||||
for range *nilPtrFunc() {
|
||||
}
|
||||
}
|
||||
func testRange2() {
|
||||
for range nilPtrFunc() {
|
||||
}
|
||||
}
|
||||
func testRange3() {
|
||||
for range *nilPtrVar {
|
||||
}
|
||||
}
|
||||
func testRange4() {
|
||||
for range nilPtrVar {
|
||||
}
|
||||
}
|
||||
|
||||
func main() {
|
||||
shouldPanic(testLen1)
|
||||
shouldNotPanic(testLen2)
|
||||
shouldNotPanic(testLen3)
|
||||
shouldNotPanic(testLen4)
|
||||
shouldPanic(testRange1)
|
||||
shouldNotPanic(testRange2)
|
||||
shouldNotPanic(testRange3)
|
||||
shouldNotPanic(testRange4)
|
||||
}
|
||||
|
||||
func shouldPanic(f func()) {
|
||||
defer func() {
|
||||
if e := recover(); e == nil {
|
||||
panic("should have panicked")
|
||||
}
|
||||
}()
|
||||
f()
|
||||
}
|
||||
func shouldNotPanic(f func()) {
|
||||
f()
|
||||
}
|
||||
24
test/fixedbugs/issue72860.go
Normal file
24
test/fixedbugs/issue72860.go
Normal file
@@ -0,0 +1,24 @@
|
||||
// run
|
||||
|
||||
// Copyright 2025 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
|
||||
|
||||
//go:noinline
|
||||
func f(p *int, b bool) int {
|
||||
valid := *p >= 0
|
||||
if !b || !valid {
|
||||
return 5
|
||||
}
|
||||
return 6
|
||||
}
|
||||
func main() {
|
||||
defer func() {
|
||||
if e := recover(); e == nil {
|
||||
println("should have panicked")
|
||||
}
|
||||
}()
|
||||
f(nil, false)
|
||||
}
|
||||
@@ -9,7 +9,7 @@
|
||||
package main
|
||||
|
||||
func main() {
|
||||
_ = copy(nil, []int{}) // ERROR "use of untyped nil|left argument must be a slice|expects slice arguments"
|
||||
_ = copy([]int{}, nil) // ERROR "use of untyped nil|second argument must be slice or string|expects slice arguments"
|
||||
_ = copy(nil, []int{}) // ERROR "use of untyped nil|left argument must be a slice|argument must be a slice; have untyped nil"
|
||||
_ = copy([]int{}, nil) // ERROR "use of untyped nil|second argument must be slice or string|argument must be a slice; have untyped nil"
|
||||
_ = 1 + true // ERROR "mismatched types untyped int and untyped bool|incompatible types|cannot convert"
|
||||
}
|
||||
|
||||
15
test/fixedbugs/issue73180.go
Normal file
15
test/fixedbugs/issue73180.go
Normal file
@@ -0,0 +1,15 @@
|
||||
// build
|
||||
|
||||
// Copyright 2025 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(a, b map[float32]int) int {
|
||||
var st *struct {
|
||||
n int
|
||||
f float32
|
||||
}
|
||||
return a[0] + b[st.f]
|
||||
}
|
||||
36
test/fixedbugs/issue73200.go
Normal file
36
test/fixedbugs/issue73200.go
Normal file
@@ -0,0 +1,36 @@
|
||||
// build
|
||||
|
||||
// Copyright 2025 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
|
||||
|
||||
var g bool
|
||||
|
||||
func main() {
|
||||
l_4 := uint32(0x6E54EE87)
|
||||
v4 := int8(-Int64FromInt64(1))
|
||||
g = int32(v4) >= safe_mod_func_int32_t_s_s(BoolInt32(l_4 >= 1), 7)
|
||||
}
|
||||
|
||||
func safe_mod_func_int32_t_s_s(si1 int32, si2 int32) (r int32) {
|
||||
var v1 int32
|
||||
if si2 == 0 {
|
||||
v1 = si1
|
||||
} else {
|
||||
v1 = si1 % si2
|
||||
}
|
||||
return v1
|
||||
}
|
||||
|
||||
func Int64FromInt64(n int64) int64 {
|
||||
return n
|
||||
}
|
||||
|
||||
func BoolInt32(b bool) int32 {
|
||||
if b {
|
||||
return 1
|
||||
}
|
||||
return 0
|
||||
}
|
||||
18
test/fixedbugs/issue73309.go
Normal file
18
test/fixedbugs/issue73309.go
Normal file
@@ -0,0 +1,18 @@
|
||||
// compile
|
||||
|
||||
// Copyright 2025 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
|
||||
|
||||
type B[T any] struct {
|
||||
a A[T]
|
||||
}
|
||||
|
||||
type A[T any] = func(B[T]) bool
|
||||
|
||||
func main() {
|
||||
var s A[int]
|
||||
println(s)
|
||||
}
|
||||
88
test/fixedbugs/issue73309b.go
Normal file
88
test/fixedbugs/issue73309b.go
Normal file
@@ -0,0 +1,88 @@
|
||||
// compile
|
||||
|
||||
// Copyright 2025 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
|
||||
|
||||
type Unsigned interface {
|
||||
~uint | ~uint8 | ~uint16 | ~uint32 | ~uint64 | ~uintptr
|
||||
}
|
||||
|
||||
// a Validator instance
|
||||
type Validator []Validable
|
||||
|
||||
type Numeric interface {
|
||||
~int | ~int8 | ~int16 | ~int32 | ~int64 | ~float32 | ~float64
|
||||
}
|
||||
|
||||
func (v Validator) Valid() bool {
|
||||
for _, field := range v {
|
||||
if !field.Validate() {
|
||||
return false
|
||||
}
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
type Validable interface {
|
||||
Validate() bool
|
||||
}
|
||||
|
||||
type FieldDef[T any] struct {
|
||||
value T
|
||||
rules []Rule[T]
|
||||
}
|
||||
|
||||
func (f FieldDef[T]) Validate() bool {
|
||||
for _, rule := range f.rules {
|
||||
if !rule(f) {
|
||||
return false
|
||||
}
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
type Rule[T any] = func(FieldDef[T]) bool
|
||||
|
||||
func Field[T any](value T, rules ...Rule[T]) *FieldDef[T] {
|
||||
return &FieldDef[T]{value: value, rules: rules}
|
||||
}
|
||||
|
||||
type StringRule = Rule[string]
|
||||
|
||||
type NumericRule[T Numeric] = Rule[T]
|
||||
|
||||
type UnsignedRule[T Unsigned] = Rule[T]
|
||||
|
||||
func MinS(n int) StringRule {
|
||||
return func(fd FieldDef[string]) bool {
|
||||
return len(fd.value) < n
|
||||
}
|
||||
}
|
||||
|
||||
func MinD[T Numeric](n T) NumericRule[T] {
|
||||
return func(fd FieldDef[T]) bool {
|
||||
return fd.value < n
|
||||
}
|
||||
}
|
||||
|
||||
func MinU[T Unsigned](n T) UnsignedRule[T] {
|
||||
return func(fd FieldDef[T]) bool {
|
||||
return fd.value < n
|
||||
}
|
||||
}
|
||||
|
||||
func main() {
|
||||
v := Validator{
|
||||
Field("test", MinS(5)),
|
||||
}
|
||||
|
||||
if !v.Valid() {
|
||||
println("invalid")
|
||||
return
|
||||
}
|
||||
|
||||
println("valid")
|
||||
}
|
||||
17
test/fixedbugs/issue73476.go
Normal file
17
test/fixedbugs/issue73476.go
Normal file
@@ -0,0 +1,17 @@
|
||||
// run
|
||||
|
||||
// Copyright 2025 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
|
||||
|
||||
//go:noinline
|
||||
func f(p *[4]int) {
|
||||
for i := range (*p) { // Note the parentheses! gofmt wants to remove them - don't let it!
|
||||
println(i)
|
||||
}
|
||||
}
|
||||
func main() {
|
||||
f(nil)
|
||||
}
|
||||
4
test/fixedbugs/issue73476.out
Normal file
4
test/fixedbugs/issue73476.out
Normal file
@@ -0,0 +1,4 @@
|
||||
0
|
||||
1
|
||||
2
|
||||
3
|
||||
20
test/fixedbugs/issue73483.go
Normal file
20
test/fixedbugs/issue73483.go
Normal file
@@ -0,0 +1,20 @@
|
||||
// run -race
|
||||
|
||||
//go:build race && cgo
|
||||
|
||||
// Copyright 2025 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
|
||||
|
||||
/*
|
||||
int v[8192];
|
||||
*/
|
||||
import "C"
|
||||
|
||||
var x [8192]C.int
|
||||
|
||||
func main() {
|
||||
copy(C.v[:], x[:])
|
||||
}
|
||||
25
test/fixedbugs/issue73491.go
Normal file
25
test/fixedbugs/issue73491.go
Normal file
@@ -0,0 +1,25 @@
|
||||
// build
|
||||
|
||||
// Copyright 2025 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
|
||||
|
||||
type T int
|
||||
|
||||
const K T = 5
|
||||
|
||||
type P struct {
|
||||
a [K]*byte
|
||||
}
|
||||
|
||||
//go:noinline
|
||||
func f(p *P) {
|
||||
for i := range K {
|
||||
p.a[i] = nil
|
||||
}
|
||||
}
|
||||
func main() {
|
||||
f(nil)
|
||||
}
|
||||
37
test/fixedbugs/issue73716.go
Normal file
37
test/fixedbugs/issue73716.go
Normal file
@@ -0,0 +1,37 @@
|
||||
// build
|
||||
|
||||
// Copyright 2025 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.
|
||||
|
||||
// Issue 73716: cmd/compile: unnamed functions missing FuncInfo
|
||||
|
||||
package main
|
||||
|
||||
import "fmt"
|
||||
|
||||
type EP func()
|
||||
type F func(EP) EP
|
||||
|
||||
func main() {
|
||||
eps := []EP{ep1, ep2}
|
||||
var h EP
|
||||
|
||||
for _, ep := range eps {
|
||||
h = F(func(e EP) EP {
|
||||
return func() {
|
||||
ep()
|
||||
e()
|
||||
}
|
||||
})(h)
|
||||
}
|
||||
h()
|
||||
}
|
||||
|
||||
func ep1() {
|
||||
fmt.Printf("ep1\n")
|
||||
}
|
||||
|
||||
func ep2() {
|
||||
fmt.Printf("ep2\n")
|
||||
}
|
||||
58
test/fixedbugs/issue73823.go
Normal file
58
test/fixedbugs/issue73823.go
Normal file
@@ -0,0 +1,58 @@
|
||||
// compile
|
||||
|
||||
// Copyright 2025 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
|
||||
|
||||
type Backend interface {
|
||||
Hash(ignores func(bucketName, keyName []byte) bool) (uint32, error)
|
||||
}
|
||||
|
||||
type backend struct {
|
||||
}
|
||||
|
||||
func first() (key []byte, value []byte) {
|
||||
return
|
||||
}
|
||||
|
||||
func (b *backend) View(fn func() error) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (b *backend) Hash(ignores func(bucketName, keyName []byte) bool) (uint32, error) {
|
||||
err := b.View(func() error {
|
||||
for next, _ := first(); next != nil; next, _ = first() {
|
||||
_ = next
|
||||
}
|
||||
return nil
|
||||
})
|
||||
return 0, err
|
||||
}
|
||||
|
||||
func defragdb() error {
|
||||
for next, _ := first(); next != nil; next, _ = first() {
|
||||
_ = f(next)
|
||||
ForEach(func(k, v []byte) error {
|
||||
_ = next
|
||||
return nil
|
||||
})
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func ForEach(fn func(k, v []byte) error) error {
|
||||
for k, v := first(); k != nil; k, v = first() {
|
||||
if err := fn(k, v); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
//go:noinline
|
||||
func f(any) string {
|
||||
return ""
|
||||
}
|
||||
34
test/fixedbugs/issue73888.go
Normal file
34
test/fixedbugs/issue73888.go
Normal file
@@ -0,0 +1,34 @@
|
||||
// run
|
||||
|
||||
// Copyright 2025 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
|
||||
|
||||
type SourceRange struct {
|
||||
x, y int
|
||||
}
|
||||
|
||||
func (r *SourceRange) String() string {
|
||||
return "hello"
|
||||
}
|
||||
|
||||
type SourceNode interface {
|
||||
SourceRange()
|
||||
}
|
||||
|
||||
type testNode SourceRange
|
||||
|
||||
func (tn testNode) SourceRange() {
|
||||
}
|
||||
|
||||
func main() {
|
||||
n := testNode(SourceRange{}) // zero value
|
||||
Errorf(n)
|
||||
}
|
||||
|
||||
//go:noinline
|
||||
func Errorf(n SourceNode) {
|
||||
n.SourceRange()
|
||||
}
|
||||
34
test/fixedbugs/issue73888b.go
Normal file
34
test/fixedbugs/issue73888b.go
Normal file
@@ -0,0 +1,34 @@
|
||||
// run
|
||||
|
||||
// Copyright 2025 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
|
||||
|
||||
type SourceRange struct {
|
||||
x, y int
|
||||
}
|
||||
|
||||
func (r *SourceRange) String() string {
|
||||
return "hello"
|
||||
}
|
||||
|
||||
type SourceNode interface {
|
||||
SourceRange()
|
||||
}
|
||||
|
||||
type testNode SourceRange
|
||||
|
||||
func (tn testNode) SourceRange() {
|
||||
}
|
||||
|
||||
func main() {
|
||||
n := testNode(SourceRange{1, 1}) // not zero value
|
||||
Errorf(n)
|
||||
}
|
||||
|
||||
//go:noinline
|
||||
func Errorf(n SourceNode) {
|
||||
n.SourceRange()
|
||||
}
|
||||
30
test/fixedbugs/issue74379.go
Normal file
30
test/fixedbugs/issue74379.go
Normal file
@@ -0,0 +1,30 @@
|
||||
// run
|
||||
|
||||
// Copyright 2025 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
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"os"
|
||||
)
|
||||
|
||||
func crashOnErr(err error) bool {
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func main() {
|
||||
defer func() {
|
||||
if recover() == nil {
|
||||
fmt.Println("failed to have expected panic")
|
||||
os.Exit(1)
|
||||
}
|
||||
}()
|
||||
fmt.Println(crashOnErr(errors.New("test error")))
|
||||
}
|
||||
32
test/fixedbugs/issue74379b.go
Normal file
32
test/fixedbugs/issue74379b.go
Normal file
@@ -0,0 +1,32 @@
|
||||
// run
|
||||
|
||||
// Copyright 2025 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
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"os"
|
||||
)
|
||||
|
||||
func crashOnErr(err error) int {
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return 10
|
||||
}
|
||||
|
||||
func main() {
|
||||
defer func() {
|
||||
if recover() == nil {
|
||||
fmt.Println("failed to have expected panic")
|
||||
os.Exit(1)
|
||||
}
|
||||
}()
|
||||
|
||||
s := make([]int, crashOnErr(errors.New("test error")))
|
||||
println("unreachable: len(s) =", len(s))
|
||||
}
|
||||
54
test/fixedbugs/issue74379c.go
Normal file
54
test/fixedbugs/issue74379c.go
Normal file
@@ -0,0 +1,54 @@
|
||||
// run
|
||||
|
||||
// Copyright 2025 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
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"os"
|
||||
)
|
||||
|
||||
type S struct{ a, b int }
|
||||
|
||||
func crashOnErr1(err error) S {
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return S{} // zero value struct
|
||||
}
|
||||
|
||||
func f1() {
|
||||
defer func() {
|
||||
if recover() == nil {
|
||||
fmt.Println("failed to have expected panic")
|
||||
os.Exit(1)
|
||||
}
|
||||
}()
|
||||
fmt.Println(crashOnErr1(errors.New("test error")))
|
||||
}
|
||||
|
||||
func crashOnErr2(err error) S {
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return S{1, 2} // not zero value struct
|
||||
}
|
||||
|
||||
func f2() {
|
||||
defer func() {
|
||||
if recover() == nil {
|
||||
fmt.Println("failed to have expected panic")
|
||||
os.Exit(1)
|
||||
}
|
||||
}()
|
||||
fmt.Println(crashOnErr2(errors.New("test error")))
|
||||
}
|
||||
|
||||
func main() {
|
||||
f1()
|
||||
f2()
|
||||
}
|
||||
Reference in New Issue
Block a user