Update to go1.24.1
This commit is contained in:
99
test/fixedbugs/issue71675.go
Normal file
99
test/fixedbugs/issue71675.go
Normal file
@@ -0,0 +1,99 @@
|
||||
// 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 i() {
|
||||
for range yieldInts {
|
||||
defer func() {
|
||||
println("I")
|
||||
recover()
|
||||
}()
|
||||
}
|
||||
// This panic causes dead code elimination of the return block.
|
||||
// The compiler should nonetheless emit a deferreturn.
|
||||
panic("i panic")
|
||||
}
|
||||
|
||||
//go:noinline
|
||||
func h() {
|
||||
defer func() {
|
||||
println("H first")
|
||||
}()
|
||||
for range yieldInts {
|
||||
defer func() {
|
||||
println("H second")
|
||||
}()
|
||||
}
|
||||
defer func() {
|
||||
println("H third")
|
||||
}()
|
||||
for range yieldIntsPanic {
|
||||
defer func() {
|
||||
println("h recover:called")
|
||||
recover()
|
||||
}()
|
||||
}
|
||||
}
|
||||
|
||||
//go:noinline
|
||||
func yieldInts(yield func(int) bool) {
|
||||
if !yield(0) {
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
//go:noinline
|
||||
func g() {
|
||||
defer func() {
|
||||
println("G first")
|
||||
}()
|
||||
for range yieldIntsPanic {
|
||||
defer func() {
|
||||
println("g recover:called")
|
||||
recover()
|
||||
}()
|
||||
}
|
||||
}
|
||||
|
||||
//go:noinline
|
||||
func yieldIntsPanic(yield func(int) bool) {
|
||||
if !yield(0) {
|
||||
return
|
||||
}
|
||||
panic("yield stop")
|
||||
}
|
||||
|
||||
//go:noinline
|
||||
func next(i int) int {
|
||||
if i == 0 {
|
||||
panic("next stop")
|
||||
}
|
||||
return i + 1
|
||||
}
|
||||
|
||||
//go:noinline
|
||||
func f() {
|
||||
defer func() {
|
||||
println("F first")
|
||||
}()
|
||||
for i := 0; i < 1; i = next(i) {
|
||||
defer func() {
|
||||
println("f recover:called")
|
||||
recover()
|
||||
}()
|
||||
}
|
||||
}
|
||||
func main() {
|
||||
f()
|
||||
println("f returned")
|
||||
g()
|
||||
println("g returned")
|
||||
h()
|
||||
println("h returned")
|
||||
i()
|
||||
println("i returned")
|
||||
|
||||
}
|
||||
13
test/fixedbugs/issue71675.out
Normal file
13
test/fixedbugs/issue71675.out
Normal file
@@ -0,0 +1,13 @@
|
||||
f recover:called
|
||||
F first
|
||||
f returned
|
||||
g recover:called
|
||||
G first
|
||||
g returned
|
||||
h recover:called
|
||||
H third
|
||||
H second
|
||||
H first
|
||||
h returned
|
||||
I
|
||||
i returned
|
||||
28
test/fixedbugs/issue71680.go
Normal file
28
test/fixedbugs/issue71680.go
Normal file
@@ -0,0 +1,28 @@
|
||||
// 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 Parser struct{}
|
||||
type Node struct{}
|
||||
|
||||
type parserState func(p *Parser) parserState
|
||||
|
||||
func parserStateData(root *Node) parserState {
|
||||
return func(p *Parser) parserState {
|
||||
return parserStateOpenMap(root)(p)
|
||||
}
|
||||
}
|
||||
|
||||
func parserStateOpenMap(root *Node) parserState {
|
||||
return func(p *Parser) parserState {
|
||||
switch {
|
||||
case p != nil:
|
||||
return parserStateData(root)(p)
|
||||
}
|
||||
return parserStateOpenMap(root)(p)
|
||||
}
|
||||
}
|
||||
23
test/fixedbugs/issue71852.go
Normal file
23
test/fixedbugs/issue71852.go
Normal file
@@ -0,0 +1,23 @@
|
||||
// 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
|
||||
|
||||
import (
|
||||
"math"
|
||||
)
|
||||
|
||||
func main() {
|
||||
test(2)
|
||||
}
|
||||
|
||||
func test(i int) {
|
||||
if i <= 0 {
|
||||
return
|
||||
}
|
||||
|
||||
_ = math.Pow10(i + 2)
|
||||
}
|
||||
29
test/fixedbugs/issue71857.go
Normal file
29
test/fixedbugs/issue71857.go
Normal file
@@ -0,0 +1,29 @@
|
||||
// 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 "sync/atomic"
|
||||
|
||||
//go:noinline
|
||||
func f(p0, p1, p2, p3, p4, p5, p6, p7 *uint64, a *atomic.Uint64) {
|
||||
old := a.Or(0xaaa)
|
||||
*p0 = old
|
||||
*p1 = old
|
||||
*p2 = old
|
||||
*p3 = old
|
||||
*p4 = old
|
||||
*p5 = old
|
||||
*p6 = old
|
||||
*p7 = old
|
||||
}
|
||||
|
||||
func main() {
|
||||
a := new(atomic.Uint64)
|
||||
p := new(uint64)
|
||||
f(p, p, p, p, p, p, p, p, a)
|
||||
|
||||
}
|
||||
50
test/fixedbugs/issue71932.go
Normal file
50
test/fixedbugs/issue71932.go
Normal file
@@ -0,0 +1,50 @@
|
||||
// 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 "runtime"
|
||||
|
||||
const C = 16
|
||||
|
||||
type T [C * C]byte
|
||||
|
||||
func main() {
|
||||
var ts []*T
|
||||
|
||||
for i := 0; i < 100; i++ {
|
||||
t := new(T)
|
||||
// Save every even object.
|
||||
if i%2 == 0 {
|
||||
ts = append(ts, t)
|
||||
}
|
||||
}
|
||||
// Make sure the odd objects are collected.
|
||||
runtime.GC()
|
||||
|
||||
for _, t := range ts {
|
||||
f(t, C, C)
|
||||
}
|
||||
}
|
||||
|
||||
//go:noinline
|
||||
func f(t *T, i, j uint) {
|
||||
if i == 0 || i > C || j == 0 || j > C {
|
||||
return // gets rid of bounds check below (via prove pass)
|
||||
}
|
||||
p := &t[i*j-1]
|
||||
*p = 0
|
||||
runtime.GC()
|
||||
*p = 0
|
||||
|
||||
// This goes badly if compiled to
|
||||
// q := &t[i*j]
|
||||
// *(q-1) = 0
|
||||
// runtime.GC()
|
||||
// *(q-1) = 0
|
||||
// as at the GC call, q is an invalid pointer
|
||||
// (it points past the end of t's allocation).
|
||||
}
|
||||
40
test/fixedbugs/issue72063.go
Normal file
40
test/fixedbugs/issue72063.go
Normal file
@@ -0,0 +1,40 @@
|
||||
// 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 "fmt"
|
||||
|
||||
// Y is the Y-combinator based on https://dreamsongs.com/Files/WhyOfY.pdf
|
||||
func Y[Endo ~func(RecFct) RecFct, RecFct ~func(T) R, T, R any](f Endo) RecFct {
|
||||
|
||||
type internal[RecFct ~func(T) R, T, R any] func(internal[RecFct, T, R]) RecFct
|
||||
|
||||
g := func(h internal[RecFct, T, R]) RecFct {
|
||||
return func(t T) R {
|
||||
return f(h(h))(t)
|
||||
}
|
||||
}
|
||||
return g(g)
|
||||
}
|
||||
|
||||
func main() {
|
||||
|
||||
fct := Y(func(r func(int) int) func(int) int {
|
||||
return func(n int) int {
|
||||
if n <= 0 {
|
||||
return 1
|
||||
}
|
||||
return n * r(n-1)
|
||||
}
|
||||
})
|
||||
|
||||
want := 3628800
|
||||
if got := fct(10); got != want {
|
||||
msg := fmt.Sprintf("unexpected result, got: %d, want: %d", got, want)
|
||||
panic(msg)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user