| 1 |
// run |
| 2 |
|
| 3 |
// Copyright 2025 The Go Authors. All rights reserved. |
| 4 |
// Use of this source code is governed by a BSD-style |
| 5 |
// license that can be found in the LICENSE file. |
| 6 |
|
| 7 |
package main |
| 8 |
|
| 9 |
import "runtime" |
| 10 |
|
| 11 |
func main() { |
| 12 |
shouldPanic(func() { |
| 13 |
g = any(func() {}) == any(func() {}) |
| 14 |
}) |
| 15 |
shouldPanic(func() { |
| 16 |
g = any(map[int]int{}) == any(map[int]int{}) |
| 17 |
}) |
| 18 |
shouldPanic(func() { |
| 19 |
g = any([]int{}) == any([]int{}) |
| 20 |
}) |
| 21 |
} |
| 22 |
|
| 23 |
var g bool |
| 24 |
|
| 25 |
func shouldPanic(f func()) { |
| 26 |
defer func() { |
| 27 |
err := recover() |
| 28 |
if err == nil { |
| 29 |
_, _, line, _ := runtime.Caller(2) |
| 30 |
println("did not panic at line", line+1) |
| 31 |
} |
| 32 |
}() |
| 33 |
|
| 34 |
f() |
| 35 |
} |