Initial commit: Go 1.23 release state
This commit is contained in:
20
test/fixedbugs/bug000.go
Normal file
20
test/fixedbugs/bug000.go
Normal file
@@ -0,0 +1,20 @@
|
||||
// run
|
||||
|
||||
// Copyright 2009 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
|
||||
|
||||
func main() {
|
||||
var x int;
|
||||
switch x {
|
||||
case 0:
|
||||
{}
|
||||
case 1:
|
||||
x = 0;
|
||||
}
|
||||
}
|
||||
/*
|
||||
bug0.go:8: case statement out of place
|
||||
*/
|
||||
11
test/fixedbugs/bug002.go
Normal file
11
test/fixedbugs/bug002.go
Normal file
@@ -0,0 +1,11 @@
|
||||
// run
|
||||
|
||||
// Copyright 2009 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
|
||||
|
||||
func main() {
|
||||
if ; false {} // compiles; should be an error (should be simplevardecl before ;)
|
||||
}
|
||||
14
test/fixedbugs/bug003.go
Normal file
14
test/fixedbugs/bug003.go
Normal file
@@ -0,0 +1,14 @@
|
||||
// run
|
||||
|
||||
// Copyright 2009 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
|
||||
|
||||
func main() {
|
||||
switch ; { case true: return; default: return }
|
||||
}
|
||||
/*
|
||||
bug003.go:6: fatal error: walkswitch: not case EMPTY
|
||||
*/
|
||||
11
test/fixedbugs/bug004.go
Normal file
11
test/fixedbugs/bug004.go
Normal file
@@ -0,0 +1,11 @@
|
||||
// run
|
||||
|
||||
// Copyright 2009 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
|
||||
|
||||
func main() {
|
||||
switch ; { case false: return; } // compiles; should be an error (should be simplevardecl before ;)
|
||||
}
|
||||
18
test/fixedbugs/bug005.go
Normal file
18
test/fixedbugs/bug005.go
Normal file
@@ -0,0 +1,18 @@
|
||||
// run
|
||||
|
||||
// Copyright 2009 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
|
||||
|
||||
func main() {
|
||||
Foo: {
|
||||
return;
|
||||
}
|
||||
goto Foo;
|
||||
}
|
||||
/*
|
||||
bug5.go:4: Foo undefined
|
||||
bug5.go:4: fatal error: walktype: switch 1 unknown op GOTO l(4)
|
||||
*/
|
||||
24
test/fixedbugs/bug006.go
Normal file
24
test/fixedbugs/bug006.go
Normal file
@@ -0,0 +1,24 @@
|
||||
// run
|
||||
|
||||
// Copyright 2009 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 "os"
|
||||
|
||||
const (
|
||||
x float64 = iota
|
||||
g float64 = 4.5 * iota
|
||||
)
|
||||
|
||||
func main() {
|
||||
if g == 0.0 {
|
||||
print("zero\n")
|
||||
}
|
||||
if g != 4.5 {
|
||||
print(" fail\n")
|
||||
os.Exit(1)
|
||||
}
|
||||
}
|
||||
24
test/fixedbugs/bug007.go
Normal file
24
test/fixedbugs/bug007.go
Normal file
@@ -0,0 +1,24 @@
|
||||
// run
|
||||
|
||||
// Copyright 2009 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 (
|
||||
Point struct {
|
||||
x, y float64
|
||||
}
|
||||
Polar Point
|
||||
)
|
||||
|
||||
func main() {
|
||||
}
|
||||
|
||||
/*
|
||||
bug7.go:5: addtyp: renaming Point to Polar
|
||||
main.go.c:14: error: redefinition of typedef ‘_T_2’
|
||||
main.go.c:13: error: previous declaration of ‘_T_2’ was here
|
||||
main.go.c:16: error: redefinition of ‘struct _T_2’
|
||||
*/
|
||||
20
test/fixedbugs/bug008.go
Normal file
20
test/fixedbugs/bug008.go
Normal file
@@ -0,0 +1,20 @@
|
||||
// run
|
||||
|
||||
// Copyright 2009 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
|
||||
|
||||
func main() {
|
||||
i5 := 5;
|
||||
|
||||
switch { // compiler crash fixable with 'switch true'
|
||||
case i5 < 5: dummy := 0; _ = dummy;
|
||||
case i5 == 5: dummy := 0; _ = dummy;
|
||||
case i5 > 5: dummy := 0; _ = dummy;
|
||||
}
|
||||
}
|
||||
/*
|
||||
Segmentation fault
|
||||
*/
|
||||
16
test/fixedbugs/bug009.go
Normal file
16
test/fixedbugs/bug009.go
Normal file
@@ -0,0 +1,16 @@
|
||||
// run
|
||||
|
||||
// Copyright 2009 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
|
||||
|
||||
|
||||
func main() {
|
||||
fired := false; _ = fired;
|
||||
}
|
||||
/*
|
||||
bug9.go:5: defaultlit: unknown literal: LITERAL-B0 a(1)
|
||||
bug9.go:5: fatal error: addvar: n=NAME-fired G0 a(1) l(5) t=<N> nil
|
||||
*/
|
||||
24
test/fixedbugs/bug010.go
Normal file
24
test/fixedbugs/bug010.go
Normal file
@@ -0,0 +1,24 @@
|
||||
// run
|
||||
|
||||
// Copyright 2009 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
|
||||
|
||||
|
||||
func f(i int, f float64) {
|
||||
i = 8
|
||||
f = 8.0
|
||||
return
|
||||
}
|
||||
|
||||
func main() {
|
||||
f(3, float64(5))
|
||||
}
|
||||
|
||||
/*
|
||||
bug10.go:5: i undefined
|
||||
bug10.go:6: illegal conversion of constant to 020({},<_o001>{<i><int32>INT32;<f><float32>FLOAT32;},{})
|
||||
bug10.go:7: error in shape across assignment
|
||||
*/
|
||||
27
test/fixedbugs/bug011.go
Normal file
27
test/fixedbugs/bug011.go
Normal file
@@ -0,0 +1,27 @@
|
||||
// run
|
||||
|
||||
// Copyright 2009 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 struct {
|
||||
x, y int
|
||||
}
|
||||
|
||||
func (t *T) m(a int, b float64) int {
|
||||
return (t.x + a) * (t.y + int(b))
|
||||
}
|
||||
|
||||
func main() {
|
||||
var t *T = new(T)
|
||||
t.x = 1
|
||||
t.y = 2
|
||||
r10 := t.m(1, 3.0)
|
||||
_ = r10
|
||||
}
|
||||
/*
|
||||
bug11.go:16: fatal error: walktype: switch 1 unknown op CALLMETH l(16) <int32>INT32
|
||||
*/
|
||||
26
test/fixedbugs/bug012.go
Normal file
26
test/fixedbugs/bug012.go
Normal file
@@ -0,0 +1,26 @@
|
||||
// run
|
||||
|
||||
// Copyright 2009 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
|
||||
|
||||
|
||||
func main() {
|
||||
var u30 uint64 = 0;
|
||||
var u31 uint64 = 1;
|
||||
_, _ = u30, u31;
|
||||
var u32 uint64 = 18446744073709551615;
|
||||
var u33 uint64 = +18446744073709551615;
|
||||
if u32 != (1<<64)-1 { panic("u32\n"); }
|
||||
if u33 != (1<<64)-1 { panic("u33\n"); }
|
||||
var i34 int64 = ^0; // note: 2's complement means ^0 == -1
|
||||
if i34 != -1 { panic("i34") }
|
||||
}
|
||||
/*
|
||||
bug12.go:5: overflow converting constant to <uint64>UINT64
|
||||
bug12.go:6: overflow converting constant to <uint64>UINT64
|
||||
bug12.go:7: overflow converting constant to <uint64>UINT64
|
||||
bug12.go:8: overflow converting constant to <uint64>UINT64
|
||||
*/
|
||||
20
test/fixedbugs/bug013.go
Normal file
20
test/fixedbugs/bug013.go
Normal file
@@ -0,0 +1,20 @@
|
||||
// run
|
||||
|
||||
// Copyright 2009 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
|
||||
|
||||
func main() {
|
||||
var cu0 uint16 = '\u1234';
|
||||
var cU1 uint32 = '\U00101234';
|
||||
_, _ = cu0, cU1;
|
||||
}
|
||||
/*
|
||||
bug13.go:4: missing '
|
||||
bug13.go:4: syntax error
|
||||
bug13.go:5: newline in string
|
||||
bug13.go:5: missing '
|
||||
bug13.go:6: newline in string
|
||||
*/
|
||||
15
test/fixedbugs/bug014.go
Normal file
15
test/fixedbugs/bug014.go
Normal file
@@ -0,0 +1,15 @@
|
||||
// errorcheck
|
||||
|
||||
// Copyright 2009 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
|
||||
|
||||
func main() {
|
||||
var c00 uint8 = '\0'; // ERROR "oct|char"
|
||||
var c01 uint8 = '\07'; // ERROR "oct|char"
|
||||
var cx0 uint8 = '\x0'; // ERROR "hex|char"
|
||||
var cx1 uint8 = '\x'; // ERROR "hex|char"
|
||||
_, _, _, _ = c00, c01, cx0, cx1
|
||||
}
|
||||
13
test/fixedbugs/bug015.go
Normal file
13
test/fixedbugs/bug015.go
Normal file
@@ -0,0 +1,13 @@
|
||||
// errorcheck
|
||||
|
||||
// Copyright 2009 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
|
||||
|
||||
func main() {
|
||||
var i33 int64;
|
||||
if i33 == (1<<64) -1 { // ERROR "overflow"
|
||||
}
|
||||
}
|
||||
18
test/fixedbugs/bug016.go
Normal file
18
test/fixedbugs/bug016.go
Normal file
@@ -0,0 +1,18 @@
|
||||
// errorcheck
|
||||
|
||||
// Copyright 2009 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
|
||||
|
||||
func main() {
|
||||
var i int = 100
|
||||
i = i << -3 // ERROR "overflows|negative"
|
||||
}
|
||||
|
||||
/*
|
||||
ixedbugs/bug016.go:7: overflow converting constant to <uint32>UINT32
|
||||
fixedbugs/bug016.go:7: illegal types for operand: AS
|
||||
(<int32>INT32)
|
||||
*/
|
||||
25
test/fixedbugs/bug017.go
Normal file
25
test/fixedbugs/bug017.go
Normal file
@@ -0,0 +1,25 @@
|
||||
// run
|
||||
|
||||
// Copyright 2009 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
|
||||
|
||||
func main() {
|
||||
var s2 string = "\a\b\f\n\r\t\v"; // \r is miscompiled
|
||||
_ = s2;
|
||||
}
|
||||
/*
|
||||
main.go.c: In function ‘main_main’:
|
||||
main.go.c:20: error: missing terminating " character
|
||||
main.go.c:21: error: missing terminating " character
|
||||
main.go.c:24: error: ‘def’ undeclared (first use in this function)
|
||||
main.go.c:24: error: (Each undeclared identifier is reported only once
|
||||
main.go.c:24: error: for each function it appears in.)
|
||||
main.go.c:24: error: syntax error before ‘def’
|
||||
main.go.c:24: error: missing terminating " character
|
||||
main.go.c:25: warning: excess elements in struct initializer
|
||||
main.go.c:25: warning: (near initialization for ‘slit’)
|
||||
main.go.c:36: error: syntax error at end of input
|
||||
*/
|
||||
22
test/fixedbugs/bug020.go
Normal file
22
test/fixedbugs/bug020.go
Normal file
@@ -0,0 +1,22 @@
|
||||
// compile
|
||||
|
||||
// Copyright 2009 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 digits string;
|
||||
|
||||
func putint(buf []byte, i, base, val int, digits string) {
|
||||
buf[i] = digits[val];
|
||||
}
|
||||
|
||||
func main() {
|
||||
}
|
||||
|
||||
/*
|
||||
uetli:~/Source/go1/test gri$ 6g bugs/bug020.go
|
||||
bugs/bug020.go:7: type of a structure field cannot be an open array
|
||||
bugs/bug020.go:7: fatal error: width of a dynamic array
|
||||
*/
|
||||
13
test/fixedbugs/bug021.go
Normal file
13
test/fixedbugs/bug021.go
Normal file
@@ -0,0 +1,13 @@
|
||||
// run
|
||||
|
||||
// Copyright 2009 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
|
||||
|
||||
func main() {
|
||||
s1 := "hi";
|
||||
s2 := "ho";
|
||||
s1 += s2;
|
||||
}
|
||||
26
test/fixedbugs/bug022.go
Normal file
26
test/fixedbugs/bug022.go
Normal file
@@ -0,0 +1,26 @@
|
||||
// errorcheck
|
||||
|
||||
// Copyright 2009 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
|
||||
|
||||
func putint(digits *string) {
|
||||
var i byte;
|
||||
i = (*digits)[7]; // compiles
|
||||
i = digits[7]; // ERROR "illegal|is not|invalid"
|
||||
_ = i;
|
||||
}
|
||||
|
||||
func main() {
|
||||
s := "asdfasdfasdfasdf";
|
||||
putint(&s);
|
||||
}
|
||||
|
||||
/*
|
||||
bug022.go:8: illegal types for operand
|
||||
(*<string>*STRING) INDEXPTR (<int32>INT32)
|
||||
bug022.go:8: illegal types for operand
|
||||
(<uint8>UINT8) AS
|
||||
*/
|
||||
30
test/fixedbugs/bug023.go
Normal file
30
test/fixedbugs/bug023.go
Normal file
@@ -0,0 +1,30 @@
|
||||
// run
|
||||
|
||||
// Copyright 2009 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 Type interface {
|
||||
TypeName() string;
|
||||
}
|
||||
|
||||
type TInt struct {
|
||||
}
|
||||
|
||||
// TInt
|
||||
func (i *TInt) TypeName() string {
|
||||
return "int";
|
||||
}
|
||||
|
||||
|
||||
func main() {
|
||||
var t Type;
|
||||
t = nil;
|
||||
_ = t;
|
||||
}
|
||||
|
||||
/*
|
||||
bug023.go:20: fatal error: naddr: const <Type>I{<TypeName>110(<_t117>{},<_o119>{},{});}
|
||||
*/
|
||||
21
test/fixedbugs/bug024.go
Normal file
21
test/fixedbugs/bug024.go
Normal file
@@ -0,0 +1,21 @@
|
||||
// run
|
||||
|
||||
// Copyright 2009 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
|
||||
|
||||
func main() {
|
||||
var i int;
|
||||
i = '\'';
|
||||
i = '\\';
|
||||
var s string;
|
||||
s = "\"";
|
||||
_, _ = i, s;
|
||||
}
|
||||
/*
|
||||
bug.go:5: unknown escape sequence: '
|
||||
bug.go:6: unknown escape sequence: \
|
||||
bug.go:8: unknown escape sequence: "
|
||||
*/
|
||||
26
test/fixedbugs/bug026.go
Normal file
26
test/fixedbugs/bug026.go
Normal file
@@ -0,0 +1,26 @@
|
||||
// run
|
||||
|
||||
// Copyright 2009 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 Element interface {
|
||||
}
|
||||
|
||||
type Vector struct {
|
||||
}
|
||||
|
||||
func (v *Vector) Insert(i int, e Element) {
|
||||
}
|
||||
|
||||
|
||||
func main() {
|
||||
type I struct { val int; }; // BUG: can't be local; works if global
|
||||
v := new(Vector);
|
||||
v.Insert(0, new(I));
|
||||
}
|
||||
/*
|
||||
check: main_sigs_I: not defined
|
||||
*/
|
||||
84
test/fixedbugs/bug027.go
Normal file
84
test/fixedbugs/bug027.go
Normal file
@@ -0,0 +1,84 @@
|
||||
// run
|
||||
|
||||
// Copyright 2009 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"
|
||||
|
||||
type Element interface {
|
||||
}
|
||||
|
||||
type Vector struct {
|
||||
nelem int
|
||||
elem []Element
|
||||
}
|
||||
|
||||
func New() *Vector {
|
||||
v := new(Vector)
|
||||
v.nelem = 0
|
||||
v.elem = make([]Element, 10)
|
||||
return v
|
||||
}
|
||||
|
||||
func (v *Vector) At(i int) Element {
|
||||
return v.elem[i]
|
||||
}
|
||||
|
||||
func (v *Vector) Insert(e Element) {
|
||||
v.elem[v.nelem] = e
|
||||
v.nelem++
|
||||
}
|
||||
|
||||
func main() {
|
||||
type I struct{ val int }
|
||||
i0 := new(I)
|
||||
i0.val = 0
|
||||
i1 := new(I)
|
||||
i1.val = 11
|
||||
i2 := new(I)
|
||||
i2.val = 222
|
||||
i3 := new(I)
|
||||
i3.val = 3333
|
||||
i4 := new(I)
|
||||
i4.val = 44444
|
||||
v := New()
|
||||
r := "hi\n"
|
||||
v.Insert(i4)
|
||||
v.Insert(i3)
|
||||
v.Insert(i2)
|
||||
v.Insert(i1)
|
||||
v.Insert(i0)
|
||||
for i := 0; i < v.nelem; i++ {
|
||||
var x *I
|
||||
x = v.At(i).(*I)
|
||||
r += fmt.Sprintln(i, x.val) // prints correct list
|
||||
}
|
||||
for i := 0; i < v.nelem; i++ {
|
||||
r += fmt.Sprintln(i, v.At(i).(*I).val)
|
||||
}
|
||||
expect := `hi
|
||||
0 44444
|
||||
1 3333
|
||||
2 222
|
||||
3 11
|
||||
4 0
|
||||
0 44444
|
||||
1 3333
|
||||
2 222
|
||||
3 11
|
||||
4 0
|
||||
`
|
||||
if r != expect {
|
||||
panic(r)
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
bug027.go:50: illegal types for operand
|
||||
(<Element>I{}) CONV (<I>{})
|
||||
bug027.go:50: illegal types for operand
|
||||
(<Element>I{}) CONV (<I>{})
|
||||
*/
|
||||
29
test/fixedbugs/bug028.go
Normal file
29
test/fixedbugs/bug028.go
Normal file
@@ -0,0 +1,29 @@
|
||||
// run
|
||||
|
||||
// Copyright 2009 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
|
||||
|
||||
|
||||
func Alloc(i int) int {
|
||||
switch i {
|
||||
default:
|
||||
return 5;
|
||||
case 1:
|
||||
return 1;
|
||||
case 10:
|
||||
return 10;
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func main() {
|
||||
s := Alloc(7);
|
||||
if s != 5 { panic("bad") }
|
||||
}
|
||||
|
||||
/*
|
||||
bug028.go:7: unreachable statements in a switch
|
||||
*/
|
||||
13
test/fixedbugs/bug030.go
Normal file
13
test/fixedbugs/bug030.go
Normal file
@@ -0,0 +1,13 @@
|
||||
// errorcheck
|
||||
|
||||
// Copyright 2009 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
|
||||
|
||||
func main() {
|
||||
var x int;
|
||||
x := 0; // ERROR "declar|:="
|
||||
_ = x;
|
||||
}
|
||||
29
test/fixedbugs/bug031.go
Normal file
29
test/fixedbugs/bug031.go
Normal file
@@ -0,0 +1,29 @@
|
||||
// run
|
||||
|
||||
// Copyright 2009 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
|
||||
|
||||
func main() {
|
||||
prog := "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"+
|
||||
"xxxxxxxxxx"+
|
||||
"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"+
|
||||
"xxxxxxxxxxxxxxxxxxxxxx"+
|
||||
"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"+
|
||||
"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"+
|
||||
"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"+
|
||||
"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"+
|
||||
"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"+
|
||||
"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"+
|
||||
"xxxxxxxxxxxxxxxxxxx"+
|
||||
"xxxxxx"+
|
||||
"xxxxxxxxxxxxxxxxxxxx"+
|
||||
"xxxxxxxx"+
|
||||
"xxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
|
||||
;
|
||||
_ = prog;
|
||||
}
|
||||
|
||||
/* Segmentation fault */
|
||||
13
test/fixedbugs/bug035.go
Normal file
13
test/fixedbugs/bug035.go
Normal file
@@ -0,0 +1,13 @@
|
||||
// errorcheck
|
||||
|
||||
// Copyright 2009 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
|
||||
|
||||
func f9(a int) (i int, f float64) {
|
||||
i := 9 // ERROR "redecl|no new"
|
||||
f := float64(9) // ERROR "redecl|no new"
|
||||
return i, f
|
||||
}
|
||||
12
test/fixedbugs/bug037.go
Normal file
12
test/fixedbugs/bug037.go
Normal file
@@ -0,0 +1,12 @@
|
||||
// errorcheck
|
||||
|
||||
// Copyright 2009 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
|
||||
|
||||
func main() {
|
||||
s := vlong(0); // ERROR "undef"
|
||||
_ = s
|
||||
}
|
||||
11
test/fixedbugs/bug039.go
Normal file
11
test/fixedbugs/bug039.go
Normal file
@@ -0,0 +1,11 @@
|
||||
// errorcheck
|
||||
|
||||
// Copyright 2009 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
|
||||
|
||||
func f (x int) { // GCCGO_ERROR "previous"
|
||||
var x int; // ERROR "redecl|redefinition"
|
||||
}
|
||||
11
test/fixedbugs/bug040.go
Normal file
11
test/fixedbugs/bug040.go
Normal file
@@ -0,0 +1,11 @@
|
||||
// errorcheck
|
||||
|
||||
// Copyright 2009 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
|
||||
|
||||
func f (x, // GCCGO_ERROR "previous"
|
||||
x int) { // ERROR "duplicate argument|redefinition|redeclared"
|
||||
}
|
||||
21
test/fixedbugs/bug045.go
Normal file
21
test/fixedbugs/bug045.go
Normal file
@@ -0,0 +1,21 @@
|
||||
// run
|
||||
|
||||
// Copyright 2009 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 struct {
|
||||
i int
|
||||
}
|
||||
|
||||
func main() {
|
||||
var ta []*T;
|
||||
|
||||
ta = new([1]*T)[0:];
|
||||
ta[0] = nil;
|
||||
}
|
||||
/*
|
||||
bug045.go:13: fatal error: goc: exit 1
|
||||
*/
|
||||
15
test/fixedbugs/bug046.go
Normal file
15
test/fixedbugs/bug046.go
Normal file
@@ -0,0 +1,15 @@
|
||||
// errorcheck
|
||||
|
||||
// Copyright 2009 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 *struct {}
|
||||
|
||||
func (x T) M () {} // ERROR "pointer|receiver"
|
||||
|
||||
/*
|
||||
bug046.go:7: illegal <this> pointer
|
||||
*/
|
||||
23
test/fixedbugs/bug047.go
Normal file
23
test/fixedbugs/bug047.go
Normal file
@@ -0,0 +1,23 @@
|
||||
// run
|
||||
|
||||
// Copyright 2009 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
|
||||
|
||||
func main() {
|
||||
|
||||
type T struct {
|
||||
s string
|
||||
f float64
|
||||
}
|
||||
var s string = "hello"
|
||||
var f float64 = 0.2
|
||||
t := T{s, f}
|
||||
|
||||
type M map[int]int
|
||||
m0 := M{7: 8}
|
||||
|
||||
_, _ = t, m0
|
||||
}
|
||||
13
test/fixedbugs/bug048.go
Normal file
13
test/fixedbugs/bug048.go
Normal file
@@ -0,0 +1,13 @@
|
||||
// run
|
||||
|
||||
// Copyright 2009 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
|
||||
|
||||
func main() {
|
||||
type M map[int] int;
|
||||
m1 := M{7 : 8};
|
||||
_ = m1;
|
||||
}
|
||||
19
test/fixedbugs/bug049.go
Normal file
19
test/fixedbugs/bug049.go
Normal file
@@ -0,0 +1,19 @@
|
||||
// errorcheck
|
||||
|
||||
// Copyright 2009 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
|
||||
|
||||
func atom(s string) {
|
||||
if s == nil { // ERROR "nil|incompatible"
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
func main() {}
|
||||
|
||||
/*
|
||||
bug047.go:4: fatal error: stringpool: not string
|
||||
*/
|
||||
8
test/fixedbugs/bug050.go
Normal file
8
test/fixedbugs/bug050.go
Normal file
@@ -0,0 +1,8 @@
|
||||
// errorcheck -d=panic
|
||||
|
||||
// Copyright 2009 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.
|
||||
|
||||
func main() { // ERROR "package"
|
||||
}
|
||||
15
test/fixedbugs/bug051.go
Normal file
15
test/fixedbugs/bug051.go
Normal file
@@ -0,0 +1,15 @@
|
||||
// errorcheck
|
||||
|
||||
// Copyright 2009 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
|
||||
|
||||
func f() int {
|
||||
return 0;
|
||||
}
|
||||
|
||||
func main() {
|
||||
const n = f(); // ERROR "const"
|
||||
}
|
||||
20
test/fixedbugs/bug052.go
Normal file
20
test/fixedbugs/bug052.go
Normal file
@@ -0,0 +1,20 @@
|
||||
// run
|
||||
|
||||
// Copyright 2009 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
|
||||
|
||||
func main() {
|
||||
c := 10;
|
||||
d := 7;
|
||||
var x [10]int;
|
||||
i := 0;
|
||||
/* this works:
|
||||
q := c/d;
|
||||
x[i] = q;
|
||||
*/
|
||||
// this doesn't:
|
||||
x[i] = c/d; // BUG segmentation fault
|
||||
}
|
||||
12
test/fixedbugs/bug053.go
Normal file
12
test/fixedbugs/bug053.go
Normal file
@@ -0,0 +1,12 @@
|
||||
// run
|
||||
|
||||
// Copyright 2009 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
|
||||
|
||||
func main() {
|
||||
var len int; // len should not be a keyword - this doesn't compile
|
||||
_ = len;
|
||||
}
|
||||
41
test/fixedbugs/bug054.go
Normal file
41
test/fixedbugs/bug054.go
Normal file
@@ -0,0 +1,41 @@
|
||||
// run
|
||||
|
||||
// Copyright 2009 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 Element interface {
|
||||
}
|
||||
|
||||
type Vector struct {
|
||||
elem []Element;
|
||||
}
|
||||
|
||||
func (v *Vector) At(i int) Element {
|
||||
return v.elem[i];
|
||||
}
|
||||
|
||||
type TStruct struct {
|
||||
name string;
|
||||
fields *Vector;
|
||||
}
|
||||
|
||||
func (s *TStruct) field(i int) *TStruct {
|
||||
return s.fields.At(i).(*TStruct);
|
||||
}
|
||||
|
||||
func main() {
|
||||
v := new(Vector);
|
||||
v.elem = make([]Element, 10);
|
||||
t := new(TStruct);
|
||||
t.name = "hi";
|
||||
v.elem[0] = t;
|
||||
s := new(TStruct);
|
||||
s.name = "foo";
|
||||
s.fields = v;
|
||||
if s.field(0).name != "hi" {
|
||||
panic("bad name")
|
||||
}
|
||||
}
|
||||
27
test/fixedbugs/bug055.go
Normal file
27
test/fixedbugs/bug055.go
Normal file
@@ -0,0 +1,27 @@
|
||||
// run
|
||||
|
||||
// Copyright 2009 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
|
||||
|
||||
func main() {
|
||||
var i int
|
||||
var j int
|
||||
if true {
|
||||
}
|
||||
{
|
||||
return
|
||||
}
|
||||
i = 0
|
||||
if true {
|
||||
} else {
|
||||
i++
|
||||
}
|
||||
type s struct{}
|
||||
i = 0
|
||||
type s2 int
|
||||
var k = func(a int) int { return a + 1 }(3)
|
||||
_, _ = j, k
|
||||
}
|
||||
22
test/fixedbugs/bug056.go
Normal file
22
test/fixedbugs/bug056.go
Normal file
@@ -0,0 +1,22 @@
|
||||
// run
|
||||
|
||||
// Copyright 2009 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
|
||||
|
||||
func frexp() (a int, b float64) {
|
||||
return 1, 2.0
|
||||
}
|
||||
|
||||
func main() {
|
||||
a, b := frexp();
|
||||
_, _ = a, b;
|
||||
}
|
||||
|
||||
/*
|
||||
bug056.go:8: illegal types for operand: AS
|
||||
(<int32>INT32)
|
||||
(<int32>INT32)
|
||||
*/
|
||||
25
test/fixedbugs/bug057.go
Normal file
25
test/fixedbugs/bug057.go
Normal file
@@ -0,0 +1,25 @@
|
||||
// compile
|
||||
|
||||
// Copyright 2009 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 struct {
|
||||
s string;
|
||||
}
|
||||
|
||||
|
||||
func main() {
|
||||
s := "";
|
||||
l1 := len(s);
|
||||
var t T;
|
||||
l2 := len(t.s); // BUG: cannot take len() of a string field
|
||||
_, _ = l1, l2;
|
||||
}
|
||||
|
||||
/*
|
||||
uetli:/home/gri/go/test/bugs gri$ 6g bug057.go
|
||||
bug057.go:14: syntax error
|
||||
*/
|
||||
23
test/fixedbugs/bug058.go
Normal file
23
test/fixedbugs/bug058.go
Normal file
@@ -0,0 +1,23 @@
|
||||
// run
|
||||
|
||||
// Copyright 2009 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 Box struct {};
|
||||
var m map[string] *Box;
|
||||
|
||||
func main() {
|
||||
m := make(map[string] *Box);
|
||||
s := "foo";
|
||||
var x *Box = nil;
|
||||
m[s] = x;
|
||||
}
|
||||
|
||||
/*
|
||||
bug058.go:9: illegal types for operand: INDEX
|
||||
(MAP[<string>*STRING]*<Box>{})
|
||||
(<string>*STRING)
|
||||
*/
|
||||
36
test/fixedbugs/bug059.go
Normal file
36
test/fixedbugs/bug059.go
Normal file
@@ -0,0 +1,36 @@
|
||||
// run
|
||||
|
||||
// Copyright 2009 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 "os"
|
||||
|
||||
func P(a []string) string {
|
||||
s := "{";
|
||||
for i := 0; i < 2; i++ {
|
||||
if i > 0 {
|
||||
s += ","
|
||||
}
|
||||
s += `"` + a[i] + `"`;
|
||||
}
|
||||
s +="}";
|
||||
return s;
|
||||
}
|
||||
|
||||
func main() {
|
||||
m := make(map[string] []string);
|
||||
as := new([2]string);
|
||||
as[0] = "0";
|
||||
as[1] = "1";
|
||||
m["0"] = as[0:];
|
||||
|
||||
a := m["0"];
|
||||
a[0] = "x";
|
||||
m["0"][0] = "deleted";
|
||||
if m["0"][0] != "deleted" {
|
||||
os.Exit(1);
|
||||
}
|
||||
}
|
||||
19
test/fixedbugs/bug060.go
Normal file
19
test/fixedbugs/bug060.go
Normal file
@@ -0,0 +1,19 @@
|
||||
// run
|
||||
|
||||
// Copyright 2009 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 "os"
|
||||
|
||||
func main() {
|
||||
m := make(map[int]int);
|
||||
m[0] = 0;
|
||||
m[0]++;
|
||||
if m[0] != 1 {
|
||||
print("map does not increment\n");
|
||||
os.Exit(1)
|
||||
}
|
||||
}
|
||||
18
test/fixedbugs/bug061.go
Normal file
18
test/fixedbugs/bug061.go
Normal file
@@ -0,0 +1,18 @@
|
||||
// run
|
||||
|
||||
// Copyright 2009 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
|
||||
|
||||
func main() {
|
||||
var s string;
|
||||
s = "0000000000000000000000000000000000000000000000000000000000"[0:7];
|
||||
_ = s;
|
||||
}
|
||||
|
||||
/*
|
||||
uetli:~/Source/go1/test/bugs gri$ 6g bug061.go
|
||||
Bus error
|
||||
*/
|
||||
11
test/fixedbugs/bug062.go
Normal file
11
test/fixedbugs/bug062.go
Normal file
@@ -0,0 +1,11 @@
|
||||
// errorcheck
|
||||
|
||||
// Copyright 2009 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
|
||||
|
||||
func main() {
|
||||
var _ string = nil // ERROR "illegal|invalid|incompatible|cannot"
|
||||
}
|
||||
8
test/fixedbugs/bug063.go
Normal file
8
test/fixedbugs/bug063.go
Normal file
@@ -0,0 +1,8 @@
|
||||
// compile
|
||||
|
||||
// Copyright 2009 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 bug063
|
||||
const c = 0 ^ 0
|
||||
22
test/fixedbugs/bug064.go
Normal file
22
test/fixedbugs/bug064.go
Normal file
@@ -0,0 +1,22 @@
|
||||
// compile
|
||||
|
||||
// Copyright 2009 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
|
||||
|
||||
func
|
||||
swap(x, y int) (u, v int) {
|
||||
return y, x
|
||||
}
|
||||
|
||||
func
|
||||
main() {
|
||||
a := 1;
|
||||
b := 2;
|
||||
a, b = swap(swap(a, b));
|
||||
if a != 2 || b != 1 {
|
||||
panic("bad swap");
|
||||
}
|
||||
}
|
||||
12
test/fixedbugs/bug065.go
Normal file
12
test/fixedbugs/bug065.go
Normal file
@@ -0,0 +1,12 @@
|
||||
// run
|
||||
|
||||
// Copyright 2009 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
|
||||
|
||||
func main() {
|
||||
k, l, m := 0,0,0;
|
||||
_, _, _ = k, l, m;
|
||||
}
|
||||
26
test/fixedbugs/bug066.go
Normal file
26
test/fixedbugs/bug066.go
Normal file
@@ -0,0 +1,26 @@
|
||||
// compile
|
||||
|
||||
// Copyright 2009 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 bug066
|
||||
|
||||
type Scope struct {
|
||||
entries map[string] *Object;
|
||||
}
|
||||
|
||||
|
||||
type Type struct {
|
||||
scope *Scope;
|
||||
}
|
||||
|
||||
|
||||
type Object struct {
|
||||
typ *Type;
|
||||
}
|
||||
|
||||
|
||||
func Lookup(scope *Scope) *Object {
|
||||
return scope.entries["foo"];
|
||||
}
|
||||
15
test/fixedbugs/bug067.go
Normal file
15
test/fixedbugs/bug067.go
Normal file
@@ -0,0 +1,15 @@
|
||||
// run
|
||||
|
||||
// Copyright 2009 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 c chan int
|
||||
|
||||
func main() {
|
||||
c = make(chan int);
|
||||
go func() { c <- 0 } ();
|
||||
<-c
|
||||
}
|
||||
19
test/fixedbugs/bug068.go
Normal file
19
test/fixedbugs/bug068.go
Normal file
@@ -0,0 +1,19 @@
|
||||
// errorcheck
|
||||
|
||||
// Copyright 2009 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.
|
||||
|
||||
// RESOLUTION: This program is illegal. We should reject all unnecessary backslashes.
|
||||
|
||||
package main
|
||||
|
||||
const c = '\''; // this works
|
||||
const s = "\'"; // ERROR "invalid|escape"
|
||||
|
||||
/*
|
||||
There is no reason why the escapes need to be different inside strings and chars.
|
||||
|
||||
uetli:~/go/test/bugs gri$ 6g bug068.go
|
||||
bug068.go:6: unknown escape sequence: '
|
||||
*/
|
||||
20
test/fixedbugs/bug069.go
Normal file
20
test/fixedbugs/bug069.go
Normal file
@@ -0,0 +1,20 @@
|
||||
// compile
|
||||
|
||||
// Copyright 2009 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
|
||||
|
||||
func main() {
|
||||
c := make(chan int);
|
||||
ok := false;
|
||||
var i int;
|
||||
|
||||
i, ok = <-c; // works
|
||||
_, _ = i, ok;
|
||||
|
||||
ca := new([2]chan int);
|
||||
i, ok = <-(ca[0]); // fails: c.go:11: bad shape across assignment - cr=1 cl=2
|
||||
_, _ = i, ok;
|
||||
}
|
||||
40
test/fixedbugs/bug070.go
Normal file
40
test/fixedbugs/bug070.go
Normal file
@@ -0,0 +1,40 @@
|
||||
// run
|
||||
|
||||
// Copyright 2009 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"
|
||||
|
||||
func main() {
|
||||
var i, k int
|
||||
var r string
|
||||
outer:
|
||||
for k = 0; k < 2; k++ {
|
||||
r += fmt.Sprintln("outer loop top k", k)
|
||||
if k != 0 {
|
||||
panic("k not zero")
|
||||
} // inner loop breaks this one every time
|
||||
for i = 0; i < 2; i++ {
|
||||
if i != 0 {
|
||||
panic("i not zero")
|
||||
} // loop breaks every time
|
||||
r += fmt.Sprintln("inner loop top i", i)
|
||||
if true {
|
||||
r += "do break\n"
|
||||
break outer
|
||||
}
|
||||
}
|
||||
}
|
||||
r += "broke\n"
|
||||
expect := `outer loop top k 0
|
||||
inner loop top i 0
|
||||
do break
|
||||
broke
|
||||
`
|
||||
if r != expect {
|
||||
panic(r)
|
||||
}
|
||||
}
|
||||
23
test/fixedbugs/bug071.go
Normal file
23
test/fixedbugs/bug071.go
Normal file
@@ -0,0 +1,23 @@
|
||||
// compile
|
||||
|
||||
// Copyright 2009 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 bug071
|
||||
|
||||
type rat struct {
|
||||
den int;
|
||||
}
|
||||
|
||||
func (u *rat) pr() {
|
||||
}
|
||||
|
||||
type dch struct {
|
||||
dat chan *rat;
|
||||
}
|
||||
|
||||
func dosplit(in *dch){
|
||||
dat := <-in.dat;
|
||||
_ = dat;
|
||||
}
|
||||
12
test/fixedbugs/bug072.go
Normal file
12
test/fixedbugs/bug072.go
Normal file
@@ -0,0 +1,12 @@
|
||||
// errorcheck
|
||||
|
||||
// Copyright 2009 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
|
||||
|
||||
func main() {
|
||||
s := string(bug); // ERROR "undef"
|
||||
_ = s
|
||||
}
|
||||
14
test/fixedbugs/bug073.go
Normal file
14
test/fixedbugs/bug073.go
Normal file
@@ -0,0 +1,14 @@
|
||||
// compile
|
||||
|
||||
// Copyright 2009 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
|
||||
|
||||
func main() {
|
||||
var s int = 0
|
||||
var x int = 0
|
||||
x = x << s // as of 1.13, these are ok
|
||||
x = x >> s // as of 1.13, these are ok
|
||||
}
|
||||
12
test/fixedbugs/bug074.go
Normal file
12
test/fixedbugs/bug074.go
Normal file
@@ -0,0 +1,12 @@
|
||||
// errorcheck
|
||||
|
||||
// Copyright 2009 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
|
||||
|
||||
func main() {
|
||||
x := string{'a', 'b', '\n'}; // ERROR "composite"
|
||||
print(x);
|
||||
}
|
||||
17
test/fixedbugs/bug075.go
Normal file
17
test/fixedbugs/bug075.go
Normal file
@@ -0,0 +1,17 @@
|
||||
// run
|
||||
|
||||
// Copyright 2009 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 struct { m map[int]int }
|
||||
func main() {
|
||||
t := new(T);
|
||||
t.m = make(map[int]int);
|
||||
var x int;
|
||||
var ok bool;
|
||||
x, ok = t.m[0]; //bug075.go:11: bad shape across assignment - cr=1 cl=2
|
||||
_, _ = x, ok;
|
||||
}
|
||||
25
test/fixedbugs/bug076.go
Normal file
25
test/fixedbugs/bug076.go
Normal file
@@ -0,0 +1,25 @@
|
||||
// build
|
||||
|
||||
// Copyright 2009 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
|
||||
|
||||
func f() {
|
||||
exit:
|
||||
;
|
||||
goto exit
|
||||
}
|
||||
|
||||
|
||||
func main() {
|
||||
exit:
|
||||
; // this should be legal (labels not properly scoped?)
|
||||
goto exit
|
||||
}
|
||||
|
||||
/*
|
||||
uetli:~/Source/go/test/bugs gri$ 6g bug076.go
|
||||
bug076.go:11: label redeclared: exit
|
||||
*/
|
||||
14
test/fixedbugs/bug077.go
Normal file
14
test/fixedbugs/bug077.go
Normal file
@@ -0,0 +1,14 @@
|
||||
// compile
|
||||
|
||||
// Copyright 2009 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
|
||||
|
||||
func main() {
|
||||
var exit int
|
||||
exit:
|
||||
_ = exit
|
||||
goto exit
|
||||
}
|
||||
16
test/fixedbugs/bug078.go
Normal file
16
test/fixedbugs/bug078.go
Normal file
@@ -0,0 +1,16 @@
|
||||
// run
|
||||
|
||||
// Copyright 2009 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
|
||||
|
||||
func dosplit(wait chan int ){
|
||||
select {
|
||||
case <-wait:
|
||||
}
|
||||
}
|
||||
|
||||
func main() {
|
||||
}
|
||||
25
test/fixedbugs/bug080.go
Normal file
25
test/fixedbugs/bug080.go
Normal file
@@ -0,0 +1,25 @@
|
||||
// compile
|
||||
|
||||
// Copyright 2009 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
|
||||
|
||||
func f1() (x int, y float64) {
|
||||
return
|
||||
}
|
||||
|
||||
func f2(x int, y float64) {
|
||||
return
|
||||
}
|
||||
|
||||
func main() {
|
||||
f2(f1()) // this should be a legal call
|
||||
}
|
||||
|
||||
/*
|
||||
bug080.go:12: illegal types for operand: CALL
|
||||
(<int32>INT32)
|
||||
({<x><int32>INT32;<y><float32>FLOAT32;})
|
||||
*/
|
||||
14
test/fixedbugs/bug081.go
Normal file
14
test/fixedbugs/bug081.go
Normal file
@@ -0,0 +1,14 @@
|
||||
// errorcheck
|
||||
|
||||
// Copyright 2009 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
|
||||
|
||||
const x x = 2 // ERROR "loop|type|cycle"
|
||||
|
||||
/*
|
||||
bug081.go:3: first constant must evaluate an expression
|
||||
Bus error
|
||||
*/
|
||||
21
test/fixedbugs/bug082.go
Normal file
21
test/fixedbugs/bug082.go
Normal file
@@ -0,0 +1,21 @@
|
||||
// run
|
||||
|
||||
// Copyright 2009 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
|
||||
|
||||
func main() {
|
||||
x := 0
|
||||
x = ^x // unary ^ not yet implemented
|
||||
if x != ^0 {
|
||||
println(x, " ", ^0)
|
||||
panic("fail")
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
uetli:~/Source/go/test/bugs gri$ 6g bug082.go
|
||||
bug082.go:7: fatal error: optoas: no entry COM-<int32>INT32
|
||||
*/
|
||||
10
test/fixedbugs/bug083.dir/bug0.go
Normal file
10
test/fixedbugs/bug083.dir/bug0.go
Normal file
@@ -0,0 +1,10 @@
|
||||
// Copyright 2009 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 bug0
|
||||
|
||||
type t0 struct {
|
||||
}
|
||||
|
||||
var V0 t0
|
||||
14
test/fixedbugs/bug083.dir/bug1.go
Normal file
14
test/fixedbugs/bug083.dir/bug1.go
Normal file
@@ -0,0 +1,14 @@
|
||||
// Copyright 2009 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 bug1
|
||||
|
||||
import "./bug0"
|
||||
|
||||
// This is expected to fail--t0 is in package bug0 and should not be
|
||||
// visible here in package bug1. The test for failure is in
|
||||
// ../bug083.go.
|
||||
|
||||
var v1 bug0.t0; // ERROR "bug0"
|
||||
|
||||
7
test/fixedbugs/bug083.go
Normal file
7
test/fixedbugs/bug083.go
Normal file
@@ -0,0 +1,7 @@
|
||||
// errorcheckdir
|
||||
|
||||
// Copyright 2009 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 ignored
|
||||
27
test/fixedbugs/bug084.go
Normal file
27
test/fixedbugs/bug084.go
Normal file
@@ -0,0 +1,27 @@
|
||||
// run
|
||||
|
||||
// Copyright 2009 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 Service struct {
|
||||
rpc [2]int
|
||||
}
|
||||
|
||||
func (s *Service) Serve(a int64) {
|
||||
if a != 1234 {
|
||||
print(a, " not 1234\n")
|
||||
panic("fail")
|
||||
}
|
||||
}
|
||||
|
||||
var arith Service
|
||||
|
||||
func main() {
|
||||
c := make(chan string)
|
||||
a := new(Service)
|
||||
go a.Serve(1234)
|
||||
_ = c
|
||||
}
|
||||
27
test/fixedbugs/bug085.go
Normal file
27
test/fixedbugs/bug085.go
Normal file
@@ -0,0 +1,27 @@
|
||||
// errorcheck
|
||||
|
||||
// Copyright 2009 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
|
||||
|
||||
var x int
|
||||
|
||||
func foo() {
|
||||
print(P.x); // ERROR "undefined"
|
||||
}
|
||||
|
||||
/*
|
||||
uetli:~/Source/go1/test/bugs gri$ 6g bug085.go
|
||||
bug085.go:6: P: undefined
|
||||
Bus error
|
||||
*/
|
||||
|
||||
/* expected scope hierarchy (outermost to innermost)
|
||||
|
||||
universe scope (contains predeclared identifiers int, float32, int32, len, etc.)
|
||||
"solar" scope (just holds the package name P so it can be found but doesn't conflict)
|
||||
global scope (the package global scope)
|
||||
local scopes (function scopes)
|
||||
*/
|
||||
23
test/fixedbugs/bug086.go
Normal file
23
test/fixedbugs/bug086.go
Normal file
@@ -0,0 +1,23 @@
|
||||
// errorcheck
|
||||
|
||||
// Copyright 2009 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
|
||||
|
||||
func f() int {
|
||||
if false {
|
||||
return 0;
|
||||
}
|
||||
// we should not be able to return successfully w/o a return statement
|
||||
} // ERROR "return"
|
||||
|
||||
func main() {
|
||||
print(f(), "\n");
|
||||
}
|
||||
|
||||
/*
|
||||
uetli:~/Source/go1/usr/gri/gosrc gri$ 6g bug.go && 6l bug.6 && 6.out
|
||||
4882
|
||||
*/
|
||||
20
test/fixedbugs/bug087.go
Normal file
20
test/fixedbugs/bug087.go
Normal file
@@ -0,0 +1,20 @@
|
||||
// compile
|
||||
|
||||
// Copyright 2009 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
|
||||
|
||||
const s string = "foo";
|
||||
|
||||
func main() {
|
||||
i := len(s); // should be legal to take len() of a constant
|
||||
_ = i;
|
||||
}
|
||||
|
||||
/*
|
||||
uetli:~/Source/go1/test/bugs gri$ 6g bug087.go
|
||||
bug087.go:6: illegal combination of literals LEN 9
|
||||
bug087.go:6: illegal combination of literals LEN 9
|
||||
*/
|
||||
9
test/fixedbugs/bug088.dir/bug0.go
Normal file
9
test/fixedbugs/bug088.dir/bug0.go
Normal file
@@ -0,0 +1,9 @@
|
||||
// Copyright 2009 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 bug0
|
||||
|
||||
var V0 func() int;
|
||||
var V1 func() (a int);
|
||||
var V2 func() (a, b int);
|
||||
23
test/fixedbugs/bug088.dir/bug1.go
Normal file
23
test/fixedbugs/bug088.dir/bug1.go
Normal file
@@ -0,0 +1,23 @@
|
||||
// Copyright 2009 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 P "./bug0"
|
||||
|
||||
func main() {
|
||||
a0 := P.V0(); // works
|
||||
a1 := P.V1(); // works
|
||||
a2, b2 := P.V2(); // doesn't work
|
||||
_, _, _, _ = a0, a1, a2, b2;
|
||||
}
|
||||
|
||||
/*
|
||||
uetli:~/Source/go1/test/bugs/bug088.dir gri$ 6g bug0.go && 6g bug1.go
|
||||
bug1.go:8: shape error across :=
|
||||
bug1.go:8: a2: undefined
|
||||
bug1.go:8: b2: undefined
|
||||
bug1.go:8: illegal types for operand: AS
|
||||
(<(bug0)P.int32>INT32)
|
||||
*/
|
||||
7
test/fixedbugs/bug088.go
Normal file
7
test/fixedbugs/bug088.go
Normal file
@@ -0,0 +1,7 @@
|
||||
// compiledir
|
||||
|
||||
// Copyright 2009 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.
|
||||
|
||||
ignored
|
||||
21
test/fixedbugs/bug089.go
Normal file
21
test/fixedbugs/bug089.go
Normal file
@@ -0,0 +1,21 @@
|
||||
// compile
|
||||
|
||||
// Copyright 2009 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 I1 interface {}
|
||||
type I2 interface { pr() }
|
||||
|
||||
func e() I1;
|
||||
|
||||
var i1 I1;
|
||||
var i2 I2;
|
||||
|
||||
func
|
||||
main() {
|
||||
|
||||
i2 = e().(I2); // bug089.go:16: fatal error: agen_inter i2i
|
||||
}
|
||||
46
test/fixedbugs/bug090.go
Normal file
46
test/fixedbugs/bug090.go
Normal file
@@ -0,0 +1,46 @@
|
||||
// errorcheck
|
||||
|
||||
// Copyright 2009 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
|
||||
|
||||
const (
|
||||
c3div2 = 3/2;
|
||||
f3div2 = 3./2.;
|
||||
)
|
||||
|
||||
func assert(t bool, s string) {
|
||||
if !t {
|
||||
panic(s)
|
||||
}
|
||||
}
|
||||
|
||||
func main() {
|
||||
var i int;
|
||||
var f float64;
|
||||
|
||||
assert(c3div2 == 1, "3/2");
|
||||
assert(f3div2 == 1.5, "3/2");
|
||||
|
||||
i = c3div2;
|
||||
assert(i == c3div2, "i == c3div2");
|
||||
|
||||
f = c3div2;
|
||||
assert(f == c3div2, "f == c3div2");
|
||||
|
||||
f = f3div2;
|
||||
assert(f == f3div2, "f == f3div2");
|
||||
|
||||
i = f3div2; // ERROR "truncate"
|
||||
assert(i == c3div2, "i == c3div2 from f3div2");
|
||||
assert(i != f3div2, "i != f3div2"); // ERROR "truncate"
|
||||
|
||||
const g float64 = 1.0;
|
||||
i = g; // ERROR "convert|incompatible|cannot"
|
||||
|
||||
const h float64 = 3.14;
|
||||
i = h; // ERROR "convert|incompatible|cannot"
|
||||
i = int(h); // ERROR "truncate|cannot convert"
|
||||
}
|
||||
26
test/fixedbugs/bug091.go
Normal file
26
test/fixedbugs/bug091.go
Normal file
@@ -0,0 +1,26 @@
|
||||
// errorcheck
|
||||
|
||||
// Copyright 2009 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
|
||||
|
||||
func f1() {
|
||||
exit:
|
||||
print("hi\n")
|
||||
goto exit
|
||||
}
|
||||
|
||||
func f2() {
|
||||
const c = 1234
|
||||
}
|
||||
|
||||
func f3() {
|
||||
i := c // ERROR "undef"
|
||||
_ = i
|
||||
}
|
||||
|
||||
func main() {
|
||||
f3()
|
||||
}
|
||||
20
test/fixedbugs/bug092.go
Normal file
20
test/fixedbugs/bug092.go
Normal file
@@ -0,0 +1,20 @@
|
||||
// run
|
||||
|
||||
// Copyright 2009 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
|
||||
|
||||
func main() {
|
||||
var a [1000] int64; // this alone works
|
||||
var b [10000] int64; // this causes a runtime crash
|
||||
_, _ = a, b;
|
||||
}
|
||||
|
||||
/*
|
||||
uetli:~/Source/go1/test/bugs gri$ 6g bug092.go && 6l bug092.6 && 6.out
|
||||
Illegal instruction
|
||||
|
||||
gri: array size matters, possibly related to stack overflow check?
|
||||
*/
|
||||
63
test/fixedbugs/bug093.go
Normal file
63
test/fixedbugs/bug093.go
Normal file
@@ -0,0 +1,63 @@
|
||||
// run
|
||||
|
||||
// Copyright 2009 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 S struct {
|
||||
}
|
||||
|
||||
func (p *S) M() {
|
||||
}
|
||||
|
||||
type I interface {
|
||||
M();
|
||||
}
|
||||
|
||||
func main() {
|
||||
var p *S = nil;
|
||||
var i I = p; // this should be possible even though p is nil: we still know the type
|
||||
i.M(); // should be possible since we know the type, and don't ever use the receiver
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
throw: ifaces2i: nil pointer
|
||||
SIGSEGV: segmentation violation
|
||||
Faulting address: 0x0
|
||||
pc: 0x1b7d
|
||||
|
||||
0x1b7d?zi
|
||||
throw(30409, 0, 0, ...)
|
||||
throw(0x76c9, 0x0, 0x0, ...)
|
||||
0x207f?zi
|
||||
sys·ifaces2i(31440, 0, 31480, ...)
|
||||
sys·ifaces2i(0x7ad0, 0x7af8, 0x0, ...)
|
||||
0x136f?zi
|
||||
main·main(1, 0, 1606416424, ...)
|
||||
main·main(0x1, 0x7fff5fbff828, 0x0, ...)
|
||||
|
||||
rax 0x1
|
||||
rbx 0x1
|
||||
rcx 0x33b5
|
||||
rdx 0x0
|
||||
rdi 0x1
|
||||
rsi 0x7684
|
||||
rbp 0x7684
|
||||
rsp 0xafb8
|
||||
r8 0x0
|
||||
r9 0x0
|
||||
r10 0x1002
|
||||
r11 0x206
|
||||
r12 0x0
|
||||
r13 0x0
|
||||
r14 0x7c48
|
||||
r15 0xa000
|
||||
rip 0x1b7d
|
||||
rflags 0x10202
|
||||
cs 0x27
|
||||
fs 0x10
|
||||
gs 0x48
|
||||
*/
|
||||
32
test/fixedbugs/bug094.go
Normal file
32
test/fixedbugs/bug094.go
Normal file
@@ -0,0 +1,32 @@
|
||||
// compile
|
||||
|
||||
// Copyright 2009 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
|
||||
|
||||
func f0() {
|
||||
const x = 0;
|
||||
}
|
||||
|
||||
|
||||
func f1() {
|
||||
x := 0;
|
||||
_ = x;
|
||||
}
|
||||
|
||||
|
||||
func main() {
|
||||
f0();
|
||||
f1();
|
||||
}
|
||||
|
||||
/*
|
||||
uetli:~/Source/go1/test/bugs gri$ 6g bug094.go && 6l bug094.6 && 6.out
|
||||
bug094.go:11: left side of := must be a name
|
||||
bad top
|
||||
. LITERAL-I0 l(343)
|
||||
bug094.go:11: fatal error: walktype: top=3 LITERAL
|
||||
uetli:~/Source/go1/test/bugs gri$
|
||||
*/
|
||||
26
test/fixedbugs/bug096.go
Normal file
26
test/fixedbugs/bug096.go
Normal file
@@ -0,0 +1,26 @@
|
||||
// compile
|
||||
|
||||
// Copyright 2009 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 A []int;
|
||||
|
||||
func main() {
|
||||
a := &A{0};
|
||||
b := &A{0, 1};
|
||||
_, _ = a, b;
|
||||
}
|
||||
|
||||
/*
|
||||
uetli:~/Source/go1/test/bugs gri$ 6g bug096.go && 6l bug096.6 && 6.out
|
||||
Trace/BPT trap
|
||||
uetli:~/Source/go1/test/bugs gri$
|
||||
*/
|
||||
|
||||
/*
|
||||
It appears that the first assignment changes the size of A from open
|
||||
into a fixed array.
|
||||
*/
|
||||
53
test/fixedbugs/bug097.go
Normal file
53
test/fixedbugs/bug097.go
Normal file
@@ -0,0 +1,53 @@
|
||||
// run
|
||||
|
||||
// Copyright 2009 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 A []int
|
||||
|
||||
func main() {
|
||||
var a [3]A
|
||||
for i := 0; i < 3; i++ {
|
||||
a[i] = A{i}
|
||||
}
|
||||
if a[0][0] != 0 {
|
||||
panic("fail a[0][0]")
|
||||
}
|
||||
if a[1][0] != 1 {
|
||||
panic("fail a[1][0]")
|
||||
}
|
||||
if a[2][0] != 2 {
|
||||
panic("fail a[2][0]")
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
uetli:~/Source/go1/test/bugs gri$ 6g bug097.go && 6l bug097.6 && 6.out
|
||||
|
||||
panic on line 342 PC=0x13c2
|
||||
0x13c2?zi
|
||||
main·main(1, 0, 1606416416, ...)
|
||||
main·main(0x1, 0x7fff5fbff820, 0x0, ...)
|
||||
SIGTRAP: trace trap
|
||||
Faulting address: 0x4558
|
||||
pc: 0x4558
|
||||
|
||||
0x4558?zi
|
||||
sys·Breakpoint(40960, 0, 45128, ...)
|
||||
sys·Breakpoint(0xa000, 0xb048, 0xa000, ...)
|
||||
0x156a?zi
|
||||
sys·panicl(342, 0, 0, ...)
|
||||
sys·panicl(0x156, 0x300000000, 0xb024, ...)
|
||||
0x13c2?zi
|
||||
main·main(1, 0, 1606416416, ...)
|
||||
main·main(0x1, 0x7fff5fbff820, 0x0, ...)
|
||||
*/
|
||||
|
||||
/* An array composite literal needs to be created freshly every time.
|
||||
It is a "construction" of an array after all. If I pass the address
|
||||
of the array to some function, it may store it globally. Same applies
|
||||
to struct literals.
|
||||
*/
|
||||
23
test/fixedbugs/bug098.go
Normal file
23
test/fixedbugs/bug098.go
Normal file
@@ -0,0 +1,23 @@
|
||||
// compile
|
||||
|
||||
// Copyright 2009 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 A []int;
|
||||
type M map[int] int;
|
||||
|
||||
func main() {
|
||||
var a *A = &A{0};
|
||||
var m *M = &M{0 : 0}; // should be legal to use & here for consistency with other composite constructors (prev. line)
|
||||
_, _ = a, m;
|
||||
}
|
||||
|
||||
/*
|
||||
uetli:~/Source/go1/test/bugs gri$ 6g bug098.go && 6l bug098.6 && 6.out
|
||||
bug098.go:10: illegal types for operand: AS
|
||||
(*MAP[<int32>INT32]<int32>INT32)
|
||||
(**MAP[<int32>INT32]<int32>INT32)
|
||||
*/
|
||||
37
test/fixedbugs/bug099.go
Normal file
37
test/fixedbugs/bug099.go
Normal file
@@ -0,0 +1,37 @@
|
||||
// run
|
||||
|
||||
// Copyright 2009 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
|
||||
|
||||
// Interface
|
||||
type I interface { F() int }
|
||||
|
||||
// Implements interface
|
||||
type S struct { }
|
||||
func (s *S) F() int { return 1 }
|
||||
|
||||
// Allocates S but returns I
|
||||
// Arg is unused but important:
|
||||
// if you take it out (and the 0s below)
|
||||
// then the bug goes away.
|
||||
func NewI(i int) I {
|
||||
return new(S)
|
||||
}
|
||||
|
||||
// Uses interface method.
|
||||
func Use(x I) {
|
||||
x.F()
|
||||
}
|
||||
|
||||
func main() {
|
||||
i := NewI(0);
|
||||
Use(i);
|
||||
|
||||
// Again, without temporary
|
||||
// Crashes because x.F is 0.
|
||||
Use(NewI(0));
|
||||
}
|
||||
|
||||
15
test/fixedbugs/bug101.go
Normal file
15
test/fixedbugs/bug101.go
Normal file
@@ -0,0 +1,15 @@
|
||||
// run
|
||||
|
||||
// Copyright 2009 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 a = []int { 1, 2, 3 }
|
||||
|
||||
func main() {
|
||||
if len(a) != 3 { panic("array len") }
|
||||
// print(a[0], " ", a[1], " ", a[2], "\n")
|
||||
if a[0] != 1 || a[1] != 2 || a[2] != 3 { panic("array contents") }
|
||||
}
|
||||
26
test/fixedbugs/bug102.go
Normal file
26
test/fixedbugs/bug102.go
Normal file
@@ -0,0 +1,26 @@
|
||||
// run
|
||||
|
||||
// Copyright 2009 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
|
||||
|
||||
func main() {
|
||||
var b [0]byte
|
||||
s := string(b[0:]) // out of bounds trap
|
||||
if s != "" {
|
||||
panic("bad convert")
|
||||
}
|
||||
var b1 = [5]byte{'h', 'e', 'l', 'l', 'o'}
|
||||
if string(b1[0:]) != "hello" {
|
||||
panic("bad convert 1")
|
||||
}
|
||||
var b2 = make([]byte, 5)
|
||||
for i := 0; i < 5; i++ {
|
||||
b2[i] = b1[i]
|
||||
}
|
||||
if string(b2) != "hello" {
|
||||
panic("bad convert 2")
|
||||
}
|
||||
}
|
||||
15
test/fixedbugs/bug103.go
Normal file
15
test/fixedbugs/bug103.go
Normal file
@@ -0,0 +1,15 @@
|
||||
// errorcheck
|
||||
|
||||
// Copyright 2009 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
|
||||
|
||||
func f() /* no return type */ {}
|
||||
|
||||
func main() {
|
||||
x := f(); // ERROR "mismatch|as value|no type"
|
||||
_ = x
|
||||
}
|
||||
|
||||
10
test/fixedbugs/bug104.go
Normal file
10
test/fixedbugs/bug104.go
Normal file
@@ -0,0 +1,10 @@
|
||||
// errorcheck
|
||||
|
||||
// Copyright 2009 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
|
||||
func f() string {
|
||||
return 0 // ERROR "conversion|type"
|
||||
}
|
||||
7
test/fixedbugs/bug106.dir/bug0.go
Normal file
7
test/fixedbugs/bug106.dir/bug0.go
Normal file
@@ -0,0 +1,7 @@
|
||||
// Copyright 2009 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 bug0
|
||||
|
||||
const A = -1
|
||||
8
test/fixedbugs/bug106.dir/bug1.go
Normal file
8
test/fixedbugs/bug106.dir/bug1.go
Normal file
@@ -0,0 +1,8 @@
|
||||
// Copyright 2009 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 bug1
|
||||
|
||||
import _ "./bug0"
|
||||
|
||||
7
test/fixedbugs/bug106.go
Normal file
7
test/fixedbugs/bug106.go
Normal file
@@ -0,0 +1,7 @@
|
||||
// compiledir
|
||||
|
||||
// Copyright 2009 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.
|
||||
|
||||
ignored
|
||||
16
test/fixedbugs/bug107.go
Normal file
16
test/fixedbugs/bug107.go
Normal file
@@ -0,0 +1,16 @@
|
||||
// errorcheck
|
||||
|
||||
// Copyright 2009 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 os "os"
|
||||
type _ os.FileInfo
|
||||
func f() (os int) {
|
||||
// In the next line "os" should refer to the result variable, not
|
||||
// to the package.
|
||||
v := os.Open("", 0, 0); // ERROR "undefined"
|
||||
_ = v
|
||||
return 0
|
||||
}
|
||||
11
test/fixedbugs/bug108.go
Normal file
11
test/fixedbugs/bug108.go
Normal file
@@ -0,0 +1,11 @@
|
||||
// errorcheck
|
||||
|
||||
// Copyright 2009 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
|
||||
func f() {
|
||||
v := 1 << 1025; // ERROR "overflow|shift count too large"
|
||||
_ = v
|
||||
}
|
||||
25
test/fixedbugs/bug109.go
Normal file
25
test/fixedbugs/bug109.go
Normal file
@@ -0,0 +1,25 @@
|
||||
// compile
|
||||
|
||||
// Copyright 2009 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 bug109
|
||||
|
||||
func f(a float64) float64 {
|
||||
e := 1.0
|
||||
e = e * a
|
||||
return e
|
||||
}
|
||||
|
||||
/*
|
||||
6g bugs/bug109.go
|
||||
bugs/bug109.go:5: illegal types for operand: MUL
|
||||
(<float64>FLOAT64)
|
||||
(<float32>FLOAT32)
|
||||
bugs/bug109.go:5: illegal types for operand: AS
|
||||
(<float64>FLOAT64)
|
||||
bugs/bug109.go:6: illegal types for operand: RETURN
|
||||
(<float32>FLOAT32)
|
||||
(<float64>FLOAT64)
|
||||
*/
|
||||
20
test/fixedbugs/bug110.go
Normal file
20
test/fixedbugs/bug110.go
Normal file
@@ -0,0 +1,20 @@
|
||||
// build
|
||||
|
||||
// Copyright 2009 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
|
||||
|
||||
const a = 0
|
||||
|
||||
func f() {
|
||||
const a = 5
|
||||
}
|
||||
|
||||
func main() {
|
||||
if a != 0 {
|
||||
println("a=", a)
|
||||
panic("fail")
|
||||
}
|
||||
}
|
||||
32
test/fixedbugs/bug111.go
Normal file
32
test/fixedbugs/bug111.go
Normal file
@@ -0,0 +1,32 @@
|
||||
// run
|
||||
|
||||
// Copyright 2009 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 ncall int;
|
||||
|
||||
type Iffy interface {
|
||||
Me() Iffy
|
||||
}
|
||||
|
||||
type Stucky struct {
|
||||
n int
|
||||
}
|
||||
|
||||
func (s *Stucky) Me() Iffy {
|
||||
ncall++;
|
||||
return s
|
||||
}
|
||||
|
||||
func main() {
|
||||
s := new(Stucky);
|
||||
i := s.Me();
|
||||
j := i.Me();
|
||||
j.Me();
|
||||
if ncall != 3 {
|
||||
panic("bug111")
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user