Add files using upload-large-folder tool
Browse filesThis view is limited to 50 files because it contains too many changes. See raw diff
- go/test/fixedbugs/issue4614.go +20 -0
- go/test/fixedbugs/issue4618.go +41 -0
- go/test/fixedbugs/issue4620.go +21 -0
- go/test/fixedbugs/issue46234.go +103 -0
- go/test/fixedbugs/issue46304.go +76 -0
- go/test/fixedbugs/issue46386.go +32 -0
- go/test/fixedbugs/issue46525.go +14 -0
- go/test/fixedbugs/issue4654.go +71 -0
- go/test/fixedbugs/issue46556.go +16 -0
- go/test/fixedbugs/issue4663.go +15 -0
- go/test/fixedbugs/issue46653.go +10 -0
- go/test/fixedbugs/issue4667.go +37 -0
- go/test/fixedbugs/issue46720.go +15 -0
- go/test/fixedbugs/issue46725.go +48 -0
- go/test/fixedbugs/issue46749.go +37 -0
- go/test/fixedbugs/issue46903.go +32 -0
- go/test/fixedbugs/issue46907.go +11 -0
- go/test/fixedbugs/issue46938.go +29 -0
- go/test/fixedbugs/issue46957.go +13 -0
- go/test/fixedbugs/issue47068.go +7 -0
- go/test/fixedbugs/issue47087.go +7 -0
- go/test/fixedbugs/issue47131.go +7 -0
- go/test/fixedbugs/issue47185.go +12 -0
- go/test/fixedbugs/issue47201.go +7 -0
- go/test/fixedbugs/issue47227.go +22 -0
- go/test/fixedbugs/issue47317.go +7 -0
- go/test/fixedbugs/issue4734.go +21 -0
- go/test/fixedbugs/issue4748.go +20 -0
- go/test/fixedbugs/issue4752.go +26 -0
- go/test/fixedbugs/issue47712.go +23 -0
- go/test/fixedbugs/issue4776.go +10 -0
- go/test/fixedbugs/issue47771.go +19 -0
- go/test/fixedbugs/issue4785.go +20 -0
- go/test/fixedbugs/issue47928.go +21 -0
- go/test/fixedbugs/issue48026.go +26 -0
- go/test/fixedbugs/issue48033.go +40 -0
- go/test/fixedbugs/issue48088.go +7 -0
- go/test/fixedbugs/issue48092.go +17 -0
- go/test/fixedbugs/issue48097.go +12 -0
- go/test/fixedbugs/issue4813.go +52 -0
- go/test/fixedbugs/issue48230.go +10 -0
- go/test/fixedbugs/issue48289.go +28 -0
- go/test/fixedbugs/issue48301.go +13 -0
- go/test/fixedbugs/issue48357.go +20 -0
- go/test/fixedbugs/issue48459.go +17 -0
- go/test/fixedbugs/issue4847.go +24 -0
- go/test/fixedbugs/issue48471.go +56 -0
- go/test/fixedbugs/issue48473.go +30 -0
- go/test/fixedbugs/issue48476.go +21 -0
- go/test/fixedbugs/issue48536.go +29 -0
go/test/fixedbugs/issue4614.go
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// compile
|
| 2 |
+
|
| 3 |
+
// Copyright 2012 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 |
+
// Issue 4614: slicing of nil slices confuses the compiler
|
| 8 |
+
// with a uintptr(nil) node.
|
| 9 |
+
|
| 10 |
+
package p
|
| 11 |
+
|
| 12 |
+
import "unsafe"
|
| 13 |
+
|
| 14 |
+
var n int
|
| 15 |
+
|
| 16 |
+
var _ = []int(nil)[1:]
|
| 17 |
+
var _ = []int(nil)[n:]
|
| 18 |
+
|
| 19 |
+
var _ = uintptr(unsafe.Pointer(nil))
|
| 20 |
+
var _ = unsafe.Pointer(uintptr(0))
|
go/test/fixedbugs/issue4618.go
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// run
|
| 2 |
+
|
| 3 |
+
// Copyright 2013 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 (
|
| 10 |
+
"fmt"
|
| 11 |
+
"os"
|
| 12 |
+
"runtime"
|
| 13 |
+
"testing"
|
| 14 |
+
)
|
| 15 |
+
|
| 16 |
+
type T struct { int }
|
| 17 |
+
|
| 18 |
+
var globl *T
|
| 19 |
+
|
| 20 |
+
func F() {
|
| 21 |
+
t := &T{}
|
| 22 |
+
globl = t
|
| 23 |
+
}
|
| 24 |
+
|
| 25 |
+
func G() {
|
| 26 |
+
t := &T{}
|
| 27 |
+
_ = t
|
| 28 |
+
}
|
| 29 |
+
|
| 30 |
+
func main() {
|
| 31 |
+
nf := testing.AllocsPerRun(100, F)
|
| 32 |
+
ng := testing.AllocsPerRun(100, G)
|
| 33 |
+
if int(nf) > 1 {
|
| 34 |
+
fmt.Printf("AllocsPerRun(100, F) = %v, want 1\n", nf)
|
| 35 |
+
os.Exit(1)
|
| 36 |
+
}
|
| 37 |
+
if int(ng) != 0 && (runtime.Compiler != "gccgo" || int(ng) != 1) {
|
| 38 |
+
fmt.Printf("AllocsPerRun(100, G) = %v, want 0\n", ng)
|
| 39 |
+
os.Exit(1)
|
| 40 |
+
}
|
| 41 |
+
}
|
go/test/fixedbugs/issue4620.go
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// run
|
| 2 |
+
|
| 3 |
+
// Copyright 2013 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 |
+
// Issue 4620: map indexes are not evaluated before assignment of other elements
|
| 8 |
+
|
| 9 |
+
package main
|
| 10 |
+
|
| 11 |
+
import "fmt"
|
| 12 |
+
|
| 13 |
+
func main() {
|
| 14 |
+
m := map[int]int{0:1}
|
| 15 |
+
i := 0
|
| 16 |
+
i, m[i] = 1, 2
|
| 17 |
+
if m[0] != 2 {
|
| 18 |
+
fmt.Println(m)
|
| 19 |
+
panic("m[i] != 2")
|
| 20 |
+
}
|
| 21 |
+
}
|
go/test/fixedbugs/issue46234.go
ADDED
|
@@ -0,0 +1,103 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// buildrun
|
| 2 |
+
|
| 3 |
+
//go:build !js && !wasip1
|
| 4 |
+
|
| 5 |
+
// Copyright 2021 The Go Authors. All rights reserved.
|
| 6 |
+
// Use of this source code is governed by a BSD-style
|
| 7 |
+
// license that can be found in the LICENSE file.
|
| 8 |
+
|
| 9 |
+
// Ensure that runtime traceback does not infinite loop for
|
| 10 |
+
// the testcase below.
|
| 11 |
+
|
| 12 |
+
package main
|
| 13 |
+
|
| 14 |
+
import (
|
| 15 |
+
"bytes"
|
| 16 |
+
"io/ioutil"
|
| 17 |
+
"log"
|
| 18 |
+
"os"
|
| 19 |
+
"os/exec"
|
| 20 |
+
"path/filepath"
|
| 21 |
+
)
|
| 22 |
+
|
| 23 |
+
const prog = `
|
| 24 |
+
|
| 25 |
+
package main
|
| 26 |
+
|
| 27 |
+
import "context"
|
| 28 |
+
|
| 29 |
+
var gpi *int
|
| 30 |
+
|
| 31 |
+
type nAO struct {
|
| 32 |
+
eE bool
|
| 33 |
+
}
|
| 34 |
+
|
| 35 |
+
type NAO func(*nAO)
|
| 36 |
+
|
| 37 |
+
func WEA() NAO {
|
| 38 |
+
return func(o *nAO) { o.eE = true }
|
| 39 |
+
}
|
| 40 |
+
|
| 41 |
+
type R struct {
|
| 42 |
+
cM *CM
|
| 43 |
+
}
|
| 44 |
+
|
| 45 |
+
type CM int
|
| 46 |
+
|
| 47 |
+
type A string
|
| 48 |
+
|
| 49 |
+
func (m *CM) NewA(ctx context.Context, cN string, nn *nAO, opts ...NAO) (*A, error) {
|
| 50 |
+
for _, o := range opts {
|
| 51 |
+
o(nn)
|
| 52 |
+
}
|
| 53 |
+
s := A("foo")
|
| 54 |
+
return &s, nil
|
| 55 |
+
}
|
| 56 |
+
|
| 57 |
+
func (r *R) CA(ctx context.Context, cN string, nn *nAO) (*int, error) {
|
| 58 |
+
cA, err := r.cM.NewA(ctx, cN, nn, WEA(), WEA())
|
| 59 |
+
if err == nil {
|
| 60 |
+
return nil, err
|
| 61 |
+
}
|
| 62 |
+
println(cA)
|
| 63 |
+
x := int(42)
|
| 64 |
+
return &x, nil
|
| 65 |
+
}
|
| 66 |
+
|
| 67 |
+
func main() {
|
| 68 |
+
c := CM(1)
|
| 69 |
+
r := R{cM: &c}
|
| 70 |
+
var ctx context.Context
|
| 71 |
+
nnr := nAO{}
|
| 72 |
+
pi, err := r.CA(ctx, "foo", nil)
|
| 73 |
+
if err != nil {
|
| 74 |
+
panic("bad")
|
| 75 |
+
}
|
| 76 |
+
println(nnr.eE)
|
| 77 |
+
gpi = pi
|
| 78 |
+
}
|
| 79 |
+
`
|
| 80 |
+
|
| 81 |
+
func main() {
|
| 82 |
+
dir, err := ioutil.TempDir("", "46234")
|
| 83 |
+
if err != nil {
|
| 84 |
+
log.Fatal(err)
|
| 85 |
+
}
|
| 86 |
+
defer os.RemoveAll(dir)
|
| 87 |
+
|
| 88 |
+
file := filepath.Join(dir, "main.go")
|
| 89 |
+
if err := ioutil.WriteFile(file, []byte(prog), 0655); err != nil {
|
| 90 |
+
log.Fatalf("Write error %v", err)
|
| 91 |
+
}
|
| 92 |
+
|
| 93 |
+
cmd := exec.Command("go", "run", file)
|
| 94 |
+
output, err := cmd.CombinedOutput()
|
| 95 |
+
if err == nil {
|
| 96 |
+
log.Fatalf("Passed, expected an error")
|
| 97 |
+
}
|
| 98 |
+
|
| 99 |
+
want := []byte("nil pointer dereference")
|
| 100 |
+
if !bytes.Contains(output, want) {
|
| 101 |
+
log.Fatalf("Unmatched error message %q:\nin\n%s\nError: %v", want, output, err)
|
| 102 |
+
}
|
| 103 |
+
}
|
go/test/fixedbugs/issue46304.go
ADDED
|
@@ -0,0 +1,76 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// run
|
| 2 |
+
|
| 3 |
+
// Copyright 2021 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 |
+
// This testcase caused a crash when the register ABI was in effect,
|
| 8 |
+
// on amd64 (problem with register allocation).
|
| 9 |
+
|
| 10 |
+
package main
|
| 11 |
+
|
| 12 |
+
type Op struct {
|
| 13 |
+
tag string
|
| 14 |
+
_x []string
|
| 15 |
+
_q [20]uint64
|
| 16 |
+
plist []P
|
| 17 |
+
}
|
| 18 |
+
|
| 19 |
+
type P struct {
|
| 20 |
+
tag string
|
| 21 |
+
_x [10]uint64
|
| 22 |
+
b bool
|
| 23 |
+
}
|
| 24 |
+
|
| 25 |
+
type M int
|
| 26 |
+
|
| 27 |
+
//go:noinline
|
| 28 |
+
func (w *M) walkP(p *P) *P {
|
| 29 |
+
np := &P{}
|
| 30 |
+
*np = *p
|
| 31 |
+
np.tag += "new"
|
| 32 |
+
return np
|
| 33 |
+
}
|
| 34 |
+
|
| 35 |
+
func (w *M) walkOp(op *Op) *Op {
|
| 36 |
+
if op == nil {
|
| 37 |
+
return nil
|
| 38 |
+
}
|
| 39 |
+
|
| 40 |
+
orig := op
|
| 41 |
+
cloned := false
|
| 42 |
+
clone := func() {
|
| 43 |
+
if !cloned {
|
| 44 |
+
cloned = true
|
| 45 |
+
op = &Op{}
|
| 46 |
+
*op = *orig
|
| 47 |
+
}
|
| 48 |
+
}
|
| 49 |
+
|
| 50 |
+
pCloned := false
|
| 51 |
+
for i := range op.plist {
|
| 52 |
+
if s := w.walkP(&op.plist[i]); s != &op.plist[i] {
|
| 53 |
+
if !pCloned {
|
| 54 |
+
pCloned = true
|
| 55 |
+
clone()
|
| 56 |
+
op.plist = make([]P, len(orig.plist))
|
| 57 |
+
copy(op.plist, orig.plist)
|
| 58 |
+
}
|
| 59 |
+
op.plist[i] = *s
|
| 60 |
+
}
|
| 61 |
+
}
|
| 62 |
+
|
| 63 |
+
return op
|
| 64 |
+
}
|
| 65 |
+
|
| 66 |
+
func main() {
|
| 67 |
+
var ww M
|
| 68 |
+
w := &ww
|
| 69 |
+
p1 := P{tag: "a"}
|
| 70 |
+
p1._x[1] = 9
|
| 71 |
+
o := Op{tag: "old", plist: []P{p1}}
|
| 72 |
+
no := w.walkOp(&o)
|
| 73 |
+
if no.plist[0].tag != "anew" {
|
| 74 |
+
panic("bad")
|
| 75 |
+
}
|
| 76 |
+
}
|
go/test/fixedbugs/issue46386.go
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// compile -p=main
|
| 2 |
+
|
| 3 |
+
// Copyright 2021 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 |
+
type I interface {
|
| 10 |
+
M() interface{}
|
| 11 |
+
}
|
| 12 |
+
|
| 13 |
+
type S1 struct{}
|
| 14 |
+
|
| 15 |
+
func (S1) M() interface{} {
|
| 16 |
+
return nil
|
| 17 |
+
}
|
| 18 |
+
|
| 19 |
+
type EI interface{}
|
| 20 |
+
|
| 21 |
+
type S struct{}
|
| 22 |
+
|
| 23 |
+
func (S) M(as interface{ I }) {}
|
| 24 |
+
|
| 25 |
+
func f() interface{ EI } {
|
| 26 |
+
return &S1{}
|
| 27 |
+
}
|
| 28 |
+
|
| 29 |
+
func main() {
|
| 30 |
+
var i interface{ I }
|
| 31 |
+
(&S{}).M(i)
|
| 32 |
+
}
|
go/test/fixedbugs/issue46525.go
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// errorcheck -lang=go1.16
|
| 2 |
+
|
| 3 |
+
// Copyright 2021 The Go Authors. All rights reserved. Use of this
|
| 4 |
+
// source code is governed by a BSD-style license that can be found in
|
| 5 |
+
// the LICENSE file.
|
| 6 |
+
|
| 7 |
+
package p
|
| 8 |
+
|
| 9 |
+
import "unsafe"
|
| 10 |
+
|
| 11 |
+
func main() {
|
| 12 |
+
_ = unsafe.Add(unsafe.Pointer(nil), 0) // ERROR "unsafe.Add requires go1.17 or later"
|
| 13 |
+
_ = unsafe.Slice(new(byte), 1) // ERROR "unsafe.Slice requires go1.17 or later"
|
| 14 |
+
}
|
go/test/fixedbugs/issue4654.go
ADDED
|
@@ -0,0 +1,71 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// errorcheck
|
| 2 |
+
|
| 3 |
+
// Copyright 2013 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 |
+
// Issue 4654.
|
| 8 |
+
// Check error for conversion and 'not used' in defer/go.
|
| 9 |
+
|
| 10 |
+
package p
|
| 11 |
+
|
| 12 |
+
import "unsafe"
|
| 13 |
+
|
| 14 |
+
func f() {
|
| 15 |
+
defer int(0) // ERROR "defer requires function call, not conversion|is not used"
|
| 16 |
+
go string([]byte("abc")) // ERROR "go requires function call, not conversion|is not used"
|
| 17 |
+
|
| 18 |
+
var c complex128
|
| 19 |
+
var f float64
|
| 20 |
+
var t struct {X int}
|
| 21 |
+
|
| 22 |
+
var x []int
|
| 23 |
+
defer append(x, 1) // ERROR "defer discards result of append|is not used"
|
| 24 |
+
defer cap(x) // ERROR "defer discards result of cap|is not used"
|
| 25 |
+
defer complex(1, 2) // ERROR "defer discards result of complex|is not used"
|
| 26 |
+
defer complex(f, 1) // ERROR "defer discards result of complex|is not used"
|
| 27 |
+
defer imag(1i) // ERROR "defer discards result of imag|is not used"
|
| 28 |
+
defer imag(c) // ERROR "defer discards result of imag|is not used"
|
| 29 |
+
defer len(x) // ERROR "defer discards result of len|is not used"
|
| 30 |
+
defer make([]int, 1) // ERROR "defer discards result of make|is not used"
|
| 31 |
+
defer make(chan bool) // ERROR "defer discards result of make|is not used"
|
| 32 |
+
defer make(map[string]int) // ERROR "defer discards result of make|is not used"
|
| 33 |
+
defer new(int) // ERROR "defer discards result of new|is not used"
|
| 34 |
+
defer real(1i) // ERROR "defer discards result of real|is not used"
|
| 35 |
+
defer real(c) // ERROR "defer discards result of real|is not used"
|
| 36 |
+
defer append(x, 1) // ERROR "defer discards result of append|is not used"
|
| 37 |
+
defer append(x, 1) // ERROR "defer discards result of append|is not used"
|
| 38 |
+
defer unsafe.Alignof(t.X) // ERROR "defer discards result of unsafe.Alignof|is not used"
|
| 39 |
+
defer unsafe.Offsetof(t.X) // ERROR "defer discards result of unsafe.Offsetof|is not used"
|
| 40 |
+
defer unsafe.Sizeof(t) // ERROR "defer discards result of unsafe.Sizeof|is not used"
|
| 41 |
+
|
| 42 |
+
defer copy(x, x) // ok
|
| 43 |
+
m := make(map[int]int)
|
| 44 |
+
defer delete(m, 1) // ok
|
| 45 |
+
defer panic(1) // ok
|
| 46 |
+
defer print(1) // ok
|
| 47 |
+
defer println(1) // ok
|
| 48 |
+
defer recover() // ok
|
| 49 |
+
|
| 50 |
+
int(0) // ERROR "int\(0\) evaluated but not used|is not used"
|
| 51 |
+
string([]byte("abc")) // ERROR "string\(.*\) evaluated but not used|is not used"
|
| 52 |
+
|
| 53 |
+
append(x, 1) // ERROR "not used"
|
| 54 |
+
cap(x) // ERROR "not used"
|
| 55 |
+
complex(1, 2) // ERROR "not used"
|
| 56 |
+
complex(f, 1) // ERROR "not used"
|
| 57 |
+
imag(1i) // ERROR "not used"
|
| 58 |
+
imag(c) // ERROR "not used"
|
| 59 |
+
len(x) // ERROR "not used"
|
| 60 |
+
make([]int, 1) // ERROR "not used"
|
| 61 |
+
make(chan bool) // ERROR "not used"
|
| 62 |
+
make(map[string]int) // ERROR "not used"
|
| 63 |
+
new(int) // ERROR "not used"
|
| 64 |
+
real(1i) // ERROR "not used"
|
| 65 |
+
real(c) // ERROR "not used"
|
| 66 |
+
append(x, 1) // ERROR "not used"
|
| 67 |
+
append(x, 1) // ERROR "not used"
|
| 68 |
+
unsafe.Alignof(t.X) // ERROR "not used"
|
| 69 |
+
unsafe.Offsetof(t.X) // ERROR "not used"
|
| 70 |
+
unsafe.Sizeof(t) // ERROR "not used"
|
| 71 |
+
}
|
go/test/fixedbugs/issue46556.go
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// compile
|
| 2 |
+
|
| 3 |
+
// Copyright 2021 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 p
|
| 8 |
+
|
| 9 |
+
type A = interface{}
|
| 10 |
+
type B interface{}
|
| 11 |
+
|
| 12 |
+
// Test that embedding both anonymous and defined types is supported.
|
| 13 |
+
type C interface {
|
| 14 |
+
A
|
| 15 |
+
B
|
| 16 |
+
}
|
go/test/fixedbugs/issue4663.go
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// errorcheck
|
| 2 |
+
|
| 3 |
+
// Copyright 2013 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 |
+
// Issue 4663.
|
| 8 |
+
// Make sure 'not used' message is placed correctly.
|
| 9 |
+
|
| 10 |
+
package main
|
| 11 |
+
|
| 12 |
+
func a(b int) int64 {
|
| 13 |
+
b // ERROR "not used"
|
| 14 |
+
return 0
|
| 15 |
+
}
|
go/test/fixedbugs/issue46653.go
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// runindir
|
| 2 |
+
|
| 3 |
+
// Copyright 2021 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 |
+
// Test to verify compiler and linker handling of multiple
|
| 8 |
+
// competing map.zero symbol definitions.
|
| 9 |
+
|
| 10 |
+
package ignored
|
go/test/fixedbugs/issue4667.go
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// run
|
| 2 |
+
|
| 3 |
+
// Copyright 2013 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 (
|
| 10 |
+
"fmt"
|
| 11 |
+
"os"
|
| 12 |
+
"testing"
|
| 13 |
+
)
|
| 14 |
+
|
| 15 |
+
var globl *int
|
| 16 |
+
|
| 17 |
+
func G() {
|
| 18 |
+
F()
|
| 19 |
+
}
|
| 20 |
+
|
| 21 |
+
func F() {
|
| 22 |
+
var x int
|
| 23 |
+
globl = &x
|
| 24 |
+
}
|
| 25 |
+
|
| 26 |
+
func main() {
|
| 27 |
+
nf := testing.AllocsPerRun(100, F)
|
| 28 |
+
ng := testing.AllocsPerRun(100, G)
|
| 29 |
+
if int(nf) > 1 {
|
| 30 |
+
fmt.Printf("AllocsPerRun(100, F) = %v, want 1\n", nf)
|
| 31 |
+
os.Exit(1)
|
| 32 |
+
}
|
| 33 |
+
if int(ng) > 1 {
|
| 34 |
+
fmt.Printf("AllocsPerRun(100, G) = %v, want 1\n", ng)
|
| 35 |
+
os.Exit(1)
|
| 36 |
+
}
|
| 37 |
+
}
|
go/test/fixedbugs/issue46720.go
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// compile
|
| 2 |
+
|
| 3 |
+
// Copyright 2021 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 p
|
| 8 |
+
|
| 9 |
+
func f() {
|
| 10 |
+
nonce := make([]byte, 24)
|
| 11 |
+
g((*[24]byte)(nonce))
|
| 12 |
+
}
|
| 13 |
+
|
| 14 |
+
//go:noinline
|
| 15 |
+
func g(*[24]byte) {}
|
go/test/fixedbugs/issue46725.go
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// run
|
| 2 |
+
|
| 3 |
+
// Copyright 2021 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 |
+
type T [4]int // N.B., [4]int avoids runtime's tiny object allocator
|
| 12 |
+
|
| 13 |
+
//go:noinline
|
| 14 |
+
func g(x []*T) ([]*T, []*T) { return x, x }
|
| 15 |
+
|
| 16 |
+
func main() {
|
| 17 |
+
const Jenny = 8675309
|
| 18 |
+
s := [10]*T{{Jenny}}
|
| 19 |
+
|
| 20 |
+
done := make(chan struct{})
|
| 21 |
+
runtime.SetFinalizer(s[0], func(p *T) { close(done) })
|
| 22 |
+
|
| 23 |
+
var h, _ interface{} = g(s[:])
|
| 24 |
+
|
| 25 |
+
if wait(done) {
|
| 26 |
+
panic("GC'd early")
|
| 27 |
+
}
|
| 28 |
+
|
| 29 |
+
if h.([]*T)[0][0] != Jenny {
|
| 30 |
+
panic("lost Jenny's number")
|
| 31 |
+
}
|
| 32 |
+
|
| 33 |
+
if !wait(done) {
|
| 34 |
+
panic("never GC'd")
|
| 35 |
+
}
|
| 36 |
+
}
|
| 37 |
+
|
| 38 |
+
func wait(done <-chan struct{}) bool {
|
| 39 |
+
for i := 0; i < 10; i++ {
|
| 40 |
+
runtime.GC()
|
| 41 |
+
select {
|
| 42 |
+
case <-done:
|
| 43 |
+
return true
|
| 44 |
+
default:
|
| 45 |
+
}
|
| 46 |
+
}
|
| 47 |
+
return false
|
| 48 |
+
}
|
go/test/fixedbugs/issue46749.go
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// errorcheck
|
| 2 |
+
|
| 3 |
+
// Copyright 2021 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 p
|
| 8 |
+
|
| 9 |
+
var s string
|
| 10 |
+
var b bool
|
| 11 |
+
var i int
|
| 12 |
+
var iface interface{}
|
| 13 |
+
|
| 14 |
+
var (
|
| 15 |
+
_ = "" + b // ERROR "invalid operation.*mismatched types.*untyped string and bool"
|
| 16 |
+
_ = "" + i // ERROR "invalid operation.*mismatched types.*untyped string and int"
|
| 17 |
+
_ = "" + nil // ERROR "invalid operation.*mismatched types.*untyped string and nil|(untyped nil)"
|
| 18 |
+
)
|
| 19 |
+
|
| 20 |
+
var (
|
| 21 |
+
_ = s + false // ERROR "invalid operation.*mismatched types.*string and untyped bool"
|
| 22 |
+
_ = s + 1 // ERROR "invalid operation.*mismatched types.*string and untyped int"
|
| 23 |
+
_ = s + nil // ERROR "invalid operation.*mismatched types.*string and nil|(untyped nil)"
|
| 24 |
+
)
|
| 25 |
+
|
| 26 |
+
var (
|
| 27 |
+
_ = "" + false // ERROR "invalid operation.*mismatched types.*untyped string and untyped bool"
|
| 28 |
+
_ = "" + 1 // ERROR "invalid operation.*mismatched types.*untyped string and untyped int"
|
| 29 |
+
)
|
| 30 |
+
|
| 31 |
+
var (
|
| 32 |
+
_ = b + 1 // ERROR "invalid operation.*mismatched types.*bool and untyped int"
|
| 33 |
+
_ = i + false // ERROR "invalid operation.*mismatched types.*int and untyped bool"
|
| 34 |
+
_ = iface + 1 // ERROR "invalid operation.*mismatched types.*interface *{} and untyped int"
|
| 35 |
+
_ = iface + 1.0 // ERROR "invalid operation.*mismatched types.*interface *{} and untyped float"
|
| 36 |
+
_ = iface + false // ERROR "invalid operation.*mismatched types.*interface *{} and bool"
|
| 37 |
+
)
|
go/test/fixedbugs/issue46903.go
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// run
|
| 2 |
+
//go:build cgo
|
| 3 |
+
|
| 4 |
+
// Copyright 2021 The Go Authors. All rights reserved.
|
| 5 |
+
// Use of this source code is governed by a BSD-style
|
| 6 |
+
// license that can be found in the LICENSE file.
|
| 7 |
+
|
| 8 |
+
package main
|
| 9 |
+
|
| 10 |
+
import "runtime/cgo"
|
| 11 |
+
|
| 12 |
+
type A struct {
|
| 13 |
+
B
|
| 14 |
+
_ cgo.Incomplete
|
| 15 |
+
}
|
| 16 |
+
type B struct{ x byte }
|
| 17 |
+
type I interface{ M() *B }
|
| 18 |
+
|
| 19 |
+
func (p *B) M() *B { return p }
|
| 20 |
+
|
| 21 |
+
var (
|
| 22 |
+
a A
|
| 23 |
+
i I = &a
|
| 24 |
+
)
|
| 25 |
+
|
| 26 |
+
func main() {
|
| 27 |
+
got, want := i.M(), &a.B
|
| 28 |
+
if got != want {
|
| 29 |
+
println(got, "!=", want)
|
| 30 |
+
panic("FAIL")
|
| 31 |
+
}
|
| 32 |
+
}
|
go/test/fixedbugs/issue46907.go
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// compile
|
| 2 |
+
|
| 3 |
+
// Copyright 2021 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 p
|
| 8 |
+
|
| 9 |
+
func f(b []byte) []byte {
|
| 10 |
+
return (*[32]byte)(b[:32])[:]
|
| 11 |
+
}
|
go/test/fixedbugs/issue46938.go
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// run -gcflags="-d=checkptr"
|
| 2 |
+
|
| 3 |
+
// Copyright 2021 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 (
|
| 10 |
+
"strings"
|
| 11 |
+
"unsafe"
|
| 12 |
+
)
|
| 13 |
+
|
| 14 |
+
func main() {
|
| 15 |
+
defer func() {
|
| 16 |
+
err := recover()
|
| 17 |
+
if err == nil {
|
| 18 |
+
panic("expected panic")
|
| 19 |
+
}
|
| 20 |
+
if got := err.(error).Error(); !strings.Contains(got, "slice bounds out of range") {
|
| 21 |
+
panic("expected panic slice out of bound, got " + got)
|
| 22 |
+
}
|
| 23 |
+
}()
|
| 24 |
+
s := make([]int64, 100)
|
| 25 |
+
p := unsafe.Pointer(&s[0])
|
| 26 |
+
n := 1000
|
| 27 |
+
|
| 28 |
+
_ = (*[10]int64)(p)[:n:n]
|
| 29 |
+
}
|
go/test/fixedbugs/issue46957.go
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// errorcheck
|
| 2 |
+
|
| 3 |
+
// Copyright 2021 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 |
+
func f(a int, b ...int) {}
|
| 10 |
+
|
| 11 |
+
func main() {
|
| 12 |
+
f(nil...) // ERROR "not enough arguments in call to f\n\thave \(nil\)\n\twant \(int, \[\]int\)|not enough arguments"
|
| 13 |
+
}
|
go/test/fixedbugs/issue47068.go
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// rundir
|
| 2 |
+
|
| 3 |
+
// Copyright 2019 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 ignored
|
go/test/fixedbugs/issue47087.go
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// rundir
|
| 2 |
+
|
| 3 |
+
// Copyright 2021 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 ignored
|
go/test/fixedbugs/issue47131.go
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// compiledir
|
| 2 |
+
|
| 3 |
+
// Copyright 2021 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 ignored
|
go/test/fixedbugs/issue47185.go
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// runindir
|
| 2 |
+
|
| 3 |
+
//go:build cgo
|
| 4 |
+
|
| 5 |
+
// Copyright 2021 The Go Authors. All rights reserved.
|
| 6 |
+
// Use of this source code is governed by a BSD-style
|
| 7 |
+
// license that can be found in the LICENSE file.
|
| 8 |
+
|
| 9 |
+
// Another test to verify compiler and linker handling of multiple
|
| 10 |
+
// competing map.zero symbol definitions.
|
| 11 |
+
|
| 12 |
+
package ignored
|
go/test/fixedbugs/issue47201.go
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// errorcheckdir
|
| 2 |
+
|
| 3 |
+
// Copyright 2021 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 ignored
|
go/test/fixedbugs/issue47227.go
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// run fake-arg-to-force-use-of-go-run
|
| 2 |
+
|
| 3 |
+
// Copyright 2021 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 |
+
//go:build cgo
|
| 8 |
+
|
| 9 |
+
package main
|
| 10 |
+
|
| 11 |
+
// void f(int *p) { *p = 0x12345678; }
|
| 12 |
+
import "C"
|
| 13 |
+
|
| 14 |
+
func main() {
|
| 15 |
+
var x C.int
|
| 16 |
+
func() {
|
| 17 |
+
defer C.f(&x)
|
| 18 |
+
}()
|
| 19 |
+
if x != 0x12345678 {
|
| 20 |
+
panic("FAIL")
|
| 21 |
+
}
|
| 22 |
+
}
|
go/test/fixedbugs/issue47317.go
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// builddir
|
| 2 |
+
|
| 3 |
+
// Copyright 2021 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 ignored
|
go/test/fixedbugs/issue4734.go
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// compile
|
| 2 |
+
|
| 3 |
+
// Copyright 2013 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 |
+
// Caused gccgo to emit multiple definitions of the same symbol.
|
| 8 |
+
|
| 9 |
+
package p
|
| 10 |
+
|
| 11 |
+
type S1 struct{}
|
| 12 |
+
|
| 13 |
+
func (s *S1) M() {}
|
| 14 |
+
|
| 15 |
+
type S2 struct {
|
| 16 |
+
F struct{ *S1 }
|
| 17 |
+
}
|
| 18 |
+
|
| 19 |
+
func F() {
|
| 20 |
+
_ = struct{ *S1 }{}
|
| 21 |
+
}
|
go/test/fixedbugs/issue4748.go
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// run
|
| 2 |
+
|
| 3 |
+
// Copyright 2013 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 |
+
// Issue 4748.
|
| 8 |
+
// This program used to complain because inlining created two exit labels.
|
| 9 |
+
|
| 10 |
+
package main
|
| 11 |
+
|
| 12 |
+
func jump() {
|
| 13 |
+
goto exit
|
| 14 |
+
exit:
|
| 15 |
+
return
|
| 16 |
+
}
|
| 17 |
+
func main() {
|
| 18 |
+
jump()
|
| 19 |
+
jump()
|
| 20 |
+
}
|
go/test/fixedbugs/issue4752.go
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// run
|
| 2 |
+
|
| 3 |
+
// Copyright 2013 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 |
+
func F(xi, yi interface{}) uint64 {
|
| 10 |
+
x, y := xi.(uint64), yi.(uint64)
|
| 11 |
+
return x &^ y
|
| 12 |
+
}
|
| 13 |
+
|
| 14 |
+
func G(xi, yi interface{}) uint64 {
|
| 15 |
+
return xi.(uint64) &^ yi.(uint64) // generates incorrect code
|
| 16 |
+
}
|
| 17 |
+
|
| 18 |
+
func main() {
|
| 19 |
+
var x, y uint64 = 0, 1 << 63
|
| 20 |
+
f := F(x, y)
|
| 21 |
+
g := G(x, y)
|
| 22 |
+
if f != 0 || g != 0 {
|
| 23 |
+
println("F", f, "G", g)
|
| 24 |
+
panic("bad")
|
| 25 |
+
}
|
| 26 |
+
}
|
go/test/fixedbugs/issue47712.go
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// compile
|
| 2 |
+
|
| 3 |
+
// Copyright 2021 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 p
|
| 8 |
+
|
| 9 |
+
func f() {
|
| 10 |
+
if false {
|
| 11 |
+
defer func() {
|
| 12 |
+
_ = recover()
|
| 13 |
+
}()
|
| 14 |
+
}
|
| 15 |
+
}
|
| 16 |
+
|
| 17 |
+
func g() {
|
| 18 |
+
for false {
|
| 19 |
+
defer func() {
|
| 20 |
+
_ = recover()
|
| 21 |
+
}()
|
| 22 |
+
}
|
| 23 |
+
}
|
go/test/fixedbugs/issue4776.go
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// errorcheck
|
| 2 |
+
|
| 3 |
+
// Copyright 2013 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 |
+
// Issue 4776: missing package declaration error should be fatal.
|
| 8 |
+
|
| 9 |
+
type MyInt int32 // ERROR "package statement must be first|package clause"
|
| 10 |
+
|
go/test/fixedbugs/issue47771.go
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// run
|
| 2 |
+
|
| 3 |
+
// Copyright 2021 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 |
+
// gofrontend miscompiled some cases of append(s, make(typ, ln)...).
|
| 8 |
+
|
| 9 |
+
package main
|
| 10 |
+
|
| 11 |
+
var g int
|
| 12 |
+
|
| 13 |
+
func main() {
|
| 14 |
+
a := []*int{&g, &g, &g, &g}
|
| 15 |
+
a = append(a[:0], make([]*int, len(a) - 1)...)
|
| 16 |
+
if len(a) != 3 || a[0] != nil || a[1] != nil || a[2] != nil {
|
| 17 |
+
panic(a)
|
| 18 |
+
}
|
| 19 |
+
}
|
go/test/fixedbugs/issue4785.go
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// run
|
| 2 |
+
|
| 3 |
+
// Copyright 2013 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 |
+
// issue 4785: used to fail to compile
|
| 8 |
+
|
| 9 |
+
package main
|
| 10 |
+
|
| 11 |
+
func t(x, y interface{}) interface{} {
|
| 12 |
+
return x.(float64) > y.(float64)
|
| 13 |
+
}
|
| 14 |
+
|
| 15 |
+
func main() {
|
| 16 |
+
v := t(1.0, 2.0)
|
| 17 |
+
if v != false {
|
| 18 |
+
panic("bad comparison")
|
| 19 |
+
}
|
| 20 |
+
}
|
go/test/fixedbugs/issue47928.go
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// run -goexperiment fieldtrack
|
| 2 |
+
|
| 3 |
+
// Copyright 2021 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 |
+
func main() {
|
| 10 |
+
var i interface{} = new(T)
|
| 11 |
+
if _, ok := i.(interface{ Bad() }); ok {
|
| 12 |
+
panic("FAIL")
|
| 13 |
+
}
|
| 14 |
+
}
|
| 15 |
+
|
| 16 |
+
type T struct{ U }
|
| 17 |
+
|
| 18 |
+
type U struct{}
|
| 19 |
+
|
| 20 |
+
//go:nointerface
|
| 21 |
+
func (*U) Bad() {}
|
go/test/fixedbugs/issue48026.go
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// compile -d=ssa/check/on
|
| 2 |
+
|
| 3 |
+
// Copyright 2021 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 p
|
| 8 |
+
|
| 9 |
+
var i int
|
| 10 |
+
|
| 11 |
+
type t struct {
|
| 12 |
+
a, b, c, d, e int
|
| 13 |
+
}
|
| 14 |
+
|
| 15 |
+
func f(p t, q int) int {
|
| 16 |
+
var a, b, c, d, e, f, g int
|
| 17 |
+
var h, i, j, k, l, m int
|
| 18 |
+
_, _, _, _, _, _, _ = a, b, c, d, e, f, g
|
| 19 |
+
_, _, _, _, _, _ = h, i, j, k, l, m
|
| 20 |
+
return 0
|
| 21 |
+
}
|
| 22 |
+
|
| 23 |
+
func g() int {
|
| 24 |
+
var v t
|
| 25 |
+
return f(v, 1<<i)
|
| 26 |
+
}
|
go/test/fixedbugs/issue48033.go
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// compile
|
| 2 |
+
|
| 3 |
+
// Copyright 2021 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 (
|
| 10 |
+
"fmt"
|
| 11 |
+
"strings"
|
| 12 |
+
)
|
| 13 |
+
|
| 14 |
+
type app struct {
|
| 15 |
+
Name string
|
| 16 |
+
}
|
| 17 |
+
|
| 18 |
+
func bug() func() {
|
| 19 |
+
return func() {
|
| 20 |
+
|
| 21 |
+
// the issue is this if true block
|
| 22 |
+
if true {
|
| 23 |
+
return
|
| 24 |
+
}
|
| 25 |
+
|
| 26 |
+
var xx = []app{}
|
| 27 |
+
var gapp app
|
| 28 |
+
for _, app := range xx {
|
| 29 |
+
if strings.ToUpper("") == app.Name {
|
| 30 |
+
fmt.Printf("%v\n", app)
|
| 31 |
+
gapp = app
|
| 32 |
+
}
|
| 33 |
+
}
|
| 34 |
+
fmt.Println(gapp)
|
| 35 |
+
}
|
| 36 |
+
}
|
| 37 |
+
|
| 38 |
+
func main() {
|
| 39 |
+
bug()
|
| 40 |
+
}
|
go/test/fixedbugs/issue48088.go
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// compiledir
|
| 2 |
+
|
| 3 |
+
// Copyright 2021 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 ignored
|
go/test/fixedbugs/issue48092.go
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// compile -B
|
| 2 |
+
|
| 3 |
+
// Copyright 2021 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 |
+
// Make sure that we can at least compile this code
|
| 8 |
+
// successfully with -B. We can't ever produce the right
|
| 9 |
+
// answer at runtime with -B, as the access must panic.
|
| 10 |
+
|
| 11 |
+
package p
|
| 12 |
+
|
| 13 |
+
type A [0]byte
|
| 14 |
+
|
| 15 |
+
func (a *A) Get(i int) byte {
|
| 16 |
+
return a[i]
|
| 17 |
+
}
|
go/test/fixedbugs/issue48097.go
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// errorcheck -complete
|
| 2 |
+
|
| 3 |
+
// Copyright 2021 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 p
|
| 8 |
+
|
| 9 |
+
func F() // ERROR "missing function body"
|
| 10 |
+
|
| 11 |
+
//go:noescape
|
| 12 |
+
func f() {} // ERROR "can only use //go:noescape with external func implementations"
|
go/test/fixedbugs/issue4813.go
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// errorcheck
|
| 2 |
+
|
| 3 |
+
// Copyright 2013 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 |
+
// Issue 4813: use of constant floats as indices.
|
| 8 |
+
|
| 9 |
+
package main
|
| 10 |
+
|
| 11 |
+
var A [3]int
|
| 12 |
+
var S []int
|
| 13 |
+
var T string
|
| 14 |
+
|
| 15 |
+
const (
|
| 16 |
+
i = 1
|
| 17 |
+
f = 2.0
|
| 18 |
+
f2 = 2.1
|
| 19 |
+
c = complex(2, 0)
|
| 20 |
+
c2 = complex(2, 1)
|
| 21 |
+
)
|
| 22 |
+
|
| 23 |
+
var (
|
| 24 |
+
vf = f
|
| 25 |
+
vc = c
|
| 26 |
+
)
|
| 27 |
+
|
| 28 |
+
var (
|
| 29 |
+
a1 = A[i]
|
| 30 |
+
a2 = A[f]
|
| 31 |
+
a3 = A[f2] // ERROR "truncated|must be integer"
|
| 32 |
+
a4 = A[c]
|
| 33 |
+
a5 = A[c2] // ERROR "truncated|must be integer"
|
| 34 |
+
a6 = A[vf] // ERROR "non-integer|must be integer"
|
| 35 |
+
a7 = A[vc] // ERROR "non-integer|must be integer"
|
| 36 |
+
|
| 37 |
+
s1 = S[i]
|
| 38 |
+
s2 = S[f]
|
| 39 |
+
s3 = S[f2] // ERROR "truncated|must be integer"
|
| 40 |
+
s4 = S[c]
|
| 41 |
+
s5 = S[c2] // ERROR "truncated|must be integer"
|
| 42 |
+
s6 = S[vf] // ERROR "non-integer|must be integer"
|
| 43 |
+
s7 = S[vc] // ERROR "non-integer|must be integer"
|
| 44 |
+
|
| 45 |
+
t1 = T[i]
|
| 46 |
+
t2 = T[f]
|
| 47 |
+
t3 = T[f2] // ERROR "truncated|must be integer"
|
| 48 |
+
t4 = T[c]
|
| 49 |
+
t5 = T[c2] // ERROR "truncated|must be integer"
|
| 50 |
+
t6 = T[vf] // ERROR "non-integer|must be integer"
|
| 51 |
+
t7 = T[vc] // ERROR "non-integer|must be integer"
|
| 52 |
+
)
|
go/test/fixedbugs/issue48230.go
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// errorcheck
|
| 2 |
+
|
| 3 |
+
// Copyright 2021 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 p
|
| 8 |
+
|
| 9 |
+
//go:embed issue48230.go // ERROR `go:embed only allowed in Go files that import "embed"`
|
| 10 |
+
var _ string
|
go/test/fixedbugs/issue48289.go
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// run
|
| 2 |
+
|
| 3 |
+
// Copyright 2021 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 "fmt"
|
| 10 |
+
|
| 11 |
+
func main() {
|
| 12 |
+
ch := make(chan int, 1)
|
| 13 |
+
|
| 14 |
+
var ptrs [2]*int
|
| 15 |
+
for i := range ptrs {
|
| 16 |
+
ch <- i
|
| 17 |
+
select {
|
| 18 |
+
case x := <-ch:
|
| 19 |
+
ptrs[i] = &x
|
| 20 |
+
}
|
| 21 |
+
}
|
| 22 |
+
|
| 23 |
+
for i, ptr := range ptrs {
|
| 24 |
+
if *ptr != i {
|
| 25 |
+
panic(fmt.Sprintf("got *ptr %d, want %d", *ptr, i))
|
| 26 |
+
}
|
| 27 |
+
}
|
| 28 |
+
}
|
go/test/fixedbugs/issue48301.go
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// errorcheck
|
| 2 |
+
|
| 3 |
+
// Copyright 2021 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 |
+
// Don't crash while reporting the error.
|
| 8 |
+
|
| 9 |
+
package p
|
| 10 |
+
|
| 11 |
+
func _() {
|
| 12 |
+
type T = T // ERROR "invalid recursive type: T refers to itself"
|
| 13 |
+
}
|
go/test/fixedbugs/issue48357.go
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// run
|
| 2 |
+
|
| 3 |
+
// Copyright 2021 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 "reflect"
|
| 10 |
+
|
| 11 |
+
type T [129]byte
|
| 12 |
+
|
| 13 |
+
func main() {
|
| 14 |
+
m := map[string]T{}
|
| 15 |
+
v := reflect.ValueOf(m)
|
| 16 |
+
v.SetMapIndex(reflect.ValueOf("a"), reflect.ValueOf(T{}))
|
| 17 |
+
g = m["a"]
|
| 18 |
+
}
|
| 19 |
+
|
| 20 |
+
var g T
|
go/test/fixedbugs/issue48459.go
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// compile
|
| 2 |
+
|
| 3 |
+
// Copyright 2021 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 |
+
func main() {
|
| 10 |
+
if true {
|
| 11 |
+
return
|
| 12 |
+
}
|
| 13 |
+
|
| 14 |
+
defer func() {
|
| 15 |
+
recover()
|
| 16 |
+
}()
|
| 17 |
+
}
|
go/test/fixedbugs/issue4847.go
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// errorcheck
|
| 2 |
+
|
| 3 |
+
// Copyright 2013 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 |
+
// Issue 4847: initialization cycle is not detected.
|
| 8 |
+
|
| 9 |
+
package p
|
| 10 |
+
|
| 11 |
+
type (
|
| 12 |
+
E int
|
| 13 |
+
S int
|
| 14 |
+
)
|
| 15 |
+
|
| 16 |
+
type matcher func(s *S) E
|
| 17 |
+
|
| 18 |
+
func matchList(s *S) E { return matcher(matchAnyFn)(s) }
|
| 19 |
+
|
| 20 |
+
var foo = matcher(matchList)
|
| 21 |
+
|
| 22 |
+
var matchAny = matcher(matchList) // ERROR "initialization cycle|depends upon itself"
|
| 23 |
+
|
| 24 |
+
func matchAnyFn(s *S) (err E) { return matchAny(s) }
|
go/test/fixedbugs/issue48471.go
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// errorcheck
|
| 2 |
+
|
| 3 |
+
// Copyright 2021 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 p
|
| 8 |
+
|
| 9 |
+
type I interface{ M(int) }
|
| 10 |
+
|
| 11 |
+
type T struct{}
|
| 12 |
+
|
| 13 |
+
type T2 struct{}
|
| 14 |
+
|
| 15 |
+
func (*T2) m(int)
|
| 16 |
+
|
| 17 |
+
type T3 struct{}
|
| 18 |
+
|
| 19 |
+
func (*T3) M(string) {}
|
| 20 |
+
|
| 21 |
+
type T4 struct{}
|
| 22 |
+
|
| 23 |
+
func (*T4) M(int)
|
| 24 |
+
|
| 25 |
+
type T5 struct{}
|
| 26 |
+
|
| 27 |
+
func (T5) m(int) {}
|
| 28 |
+
|
| 29 |
+
type T6 struct{}
|
| 30 |
+
|
| 31 |
+
func (T6) m(int) string { return "" }
|
| 32 |
+
|
| 33 |
+
func f(I)
|
| 34 |
+
|
| 35 |
+
func g() {
|
| 36 |
+
f(new(T)) // ERROR "cannot use new\(T\) \(.*type \*T\) as I value in argument to f: \*T does not implement I \(missing method M\)"
|
| 37 |
+
|
| 38 |
+
var i I
|
| 39 |
+
i = new(T) // ERROR "cannot use new\(T\) \(.*type \*T\) as I value in assignment: \*T does not implement I \(missing method M\)"
|
| 40 |
+
i = I(new(T)) // ERROR "cannot convert new\(T\) \(.*type \*T\) to type I: \*T does not implement I \(missing method M\)"
|
| 41 |
+
i = new(T2) // ERROR "cannot use new\(T2\) \(.*type \*T2\) as I value in assignment: \*T2 does not implement I \(missing method M\)\n\t\thave m\(int\)\n\t\twant M\(int\)"
|
| 42 |
+
|
| 43 |
+
i = new(T3) // ERROR "cannot use new\(T3\) \(.*type \*T3\) as I value in assignment: \*T3 does not implement I \(wrong type for method M\)\n\t\thave M\(string\)\n\t\twant M\(int\)"
|
| 44 |
+
|
| 45 |
+
i = T4{} // ERROR "cannot use T4\{\} \(.*type T4\) as I value in assignment: T4 does not implement I \(method M has pointer receiver\)"
|
| 46 |
+
i = new(I) // ERROR "cannot use new\(I\) \(.*type \*I\) as I value in assignment: \*I does not implement I \(type \*I is pointer to interface, not interface\)"
|
| 47 |
+
|
| 48 |
+
_ = i.(*T2) // ERROR "impossible type assertion: i.\(\*T2\)\n\t\*T2 does not implement I \(missing method M\)\n\t\thave m\(int\)\n\t\twant M\(int\)"
|
| 49 |
+
_ = i.(*T3) // ERROR "impossible type assertion: i.\(\*T3\)\n\t\*T3 does not implement I \(wrong type for method M\)\n\t\thave M\(string\)\n\t\twant M\(int\)"
|
| 50 |
+
_ = i.(T5) // ERROR ""impossible type assertion: i.\(T5\)\n\tT5 does not implement I \(missing method M\)\n\t\thave m\(int\)\n\t\twant M\(int\)"
|
| 51 |
+
_ = i.(T6) // ERROR "impossible type assertion: i.\(T6\)\n\tT6 does not implement I \(missing method M\)\n\t\thave m\(int\) string\n\t\twant M\(int\)"
|
| 52 |
+
|
| 53 |
+
var t *T4
|
| 54 |
+
t = i // ERROR "cannot use i \(variable of interface type I\) as \*T4 value in assignment: need type assertion"
|
| 55 |
+
_ = t
|
| 56 |
+
}
|
go/test/fixedbugs/issue48473.go
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// run
|
| 2 |
+
|
| 3 |
+
// Copyright 2021 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 "fmt"
|
| 10 |
+
|
| 11 |
+
func f(x uint64) uint64 {
|
| 12 |
+
s := "\x04"
|
| 13 |
+
c := s[0]
|
| 14 |
+
return x - x<<c<<4
|
| 15 |
+
}
|
| 16 |
+
|
| 17 |
+
func g(x uint32) uint32 {
|
| 18 |
+
s := "\x04"
|
| 19 |
+
c := s[0]
|
| 20 |
+
return x - x<<c<<4
|
| 21 |
+
}
|
| 22 |
+
|
| 23 |
+
func main() {
|
| 24 |
+
if want, got := uint64(0xffffffffffffff01), f(1); want != got {
|
| 25 |
+
panic(fmt.Sprintf("want %x got %x", want, got))
|
| 26 |
+
}
|
| 27 |
+
if want, got := uint32(0xffffff01), g(1); want != got {
|
| 28 |
+
panic(fmt.Sprintf("want %x got %x", want, got))
|
| 29 |
+
}
|
| 30 |
+
}
|
go/test/fixedbugs/issue48476.go
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// run
|
| 2 |
+
|
| 3 |
+
// Copyright 2021 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 "fmt"
|
| 10 |
+
|
| 11 |
+
//go:noinline
|
| 12 |
+
func f(x uint64) uint64 {
|
| 13 |
+
s := "\x04"
|
| 14 |
+
c := s[0]
|
| 15 |
+
return x << c << 4
|
| 16 |
+
}
|
| 17 |
+
func main() {
|
| 18 |
+
if want, got := uint64(1<<8), f(1); want != got {
|
| 19 |
+
panic(fmt.Sprintf("want %x got %x", want, got))
|
| 20 |
+
}
|
| 21 |
+
}
|
go/test/fixedbugs/issue48536.go
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// run
|
| 2 |
+
|
| 3 |
+
// Copyright 2021 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 "unsafe"
|
| 10 |
+
|
| 11 |
+
var i = 257
|
| 12 |
+
|
| 13 |
+
func main() {
|
| 14 |
+
var buf [10]byte
|
| 15 |
+
p0 := unsafe.Pointer(&buf[0])
|
| 16 |
+
p1 := unsafe.Pointer(&buf[1])
|
| 17 |
+
|
| 18 |
+
if p := unsafe.Add(p0, uint8(i)); p != p1 {
|
| 19 |
+
println("FAIL:", p, "!=", p1)
|
| 20 |
+
}
|
| 21 |
+
|
| 22 |
+
var x uint8
|
| 23 |
+
if i != 0 {
|
| 24 |
+
x = 1
|
| 25 |
+
}
|
| 26 |
+
if p := unsafe.Add(p0, x); p != p1 {
|
| 27 |
+
println("FAIL:", p, "!=", p1)
|
| 28 |
+
}
|
| 29 |
+
}
|