code
stringlengths
10
1.34M
language
stringclasses
1 value
// $G $D/$F.go && $L $F.$A && ./$A.out // 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 = 1844674407370...
Go
// errchk $G $D/$F.go // 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 int) { // GCCGO_ERROR "previous" var x int; // ERROR "redecl|redefinition" }
Go
//errchk $G $D/$F.go // 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 int func f() { var x struct { T }; var y struct { T T }; x = y; // ERROR "cannot|incompatible" _ = x; } type T1...
Go
// $G $D/$F.go && $L $F.$A && ./$A.out // 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 { panic(a, " not 12...
Go
// $G $D/$F.go || echo BUG: should 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 b1 []byte; s1 := string(b1); println(len(s1)); // prints 0 b2 := ([]byte)(nil)...
Go
// $G $D/$F.go && $L $F.$A && ./$A.out // 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. // used to panic because 6g didn't generate // the code to fill in the ... argument to fmt.Sprint. package main import...
Go
// errchk $G $D/$F.go // 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 { // ERROR "return|control" if false { return 0; } // we should not be able to return successfully w/o a ...
Go
// $G $D/$F.go && $L $F.$A && ./$A.out // 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() { nchar := 0; a := []int { '日', '本', '語', 0xFFFD }; for _, char := range "日本語\xc0" { if n...
Go
// $G $D/$F.go && $L $F.$A && ./$A.out || echo BUG: bug147 // 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 "time" func main() { var count int; c := make(chan byte); go func(c chan byte...
Go
// errchk $G $D/$F.go // 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 v1 = ([10]int)(nil); // ERROR "illegal|nil|invalid" var v2 [10]int = nil; // ERROR "illegal|nil|incompatible" var v3 [1...
Go
// errchk $G $D/$F.go // 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, x int // ERROR "duplicate" }
Go
// 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 bug2 import _ "./bug1" import "./bug0" type T2 struct { t bug0.T } func fn(p *T2) int { // This reference should be invalid, because bug0.T.i is lo...
Go
// 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 T struct { i int }
Go
// 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" type T struct { t bug0.T }
Go
// $G $D/$F.go && $L $F.$A && ./$A.out || echo BUG: bug116 // 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() { bad := false; if (-5>>1) != -3 { println("-5>>1 =", -5>>1, "want -3"...
Go
// errchk $G $D/$F.go // 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 func() type I interface { f, g (); // ERROR "syntax|signature" } type J interface { h T; // ERROR "syntax|signa...
Go
// $G $D/$F.go || echo BUG: bug173 // 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. // these used to fail because the runtime // functions that get called to implement them // expected string, not T. package...
Go
// errchk $G $D/$F.go // 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 // same const identifier declared twice should not be accepted const none = 0 // GCCGO_ERROR "previous" const none = 1; /...
Go
// ! $G $D/$F.go >/dev/null // # ignoring error messages... // 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, x int) { // BUG redeclaration error }
Go
// errchk $G $D/$F.go // 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 = iota func f(x int) { } func main() { f(X); f(iota); // ERROR "iota" f(X); }
Go
// $G $D/$F.go && $L $F.$A && ./$A.out // 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 ;) }
Go
// errchk $G $D/$F.go // 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() { a := true; a |= a; // ERROR "illegal.*OR|bool|expected" }
Go
// 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
Go
// 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 i...
Go
// errchk $G $D/$F.go // 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|invali...
Go
// $G $D/$F.go && $L $F.$A && ./$A.out // 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 { nelem int; elem []Element; } func New() *Vector { v :...
Go
// $G $D/$F.go || echo BUG: should 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() { x := 0; // this compiles switch x { case 0: } // this doesn't but should switch...
Go
// $G $D/$F.go && $L $F.$A && ./$A.out // 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 ...
Go
// $G $D/$F.go || echo BUG should 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() { L1: L2: for i := 0; i < 10; i++ { print(i); break L2; } L3: ; L4: for i := 0; i < 1...
Go
// $G $D/$F.go || echo BUG: should 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; }
Go
// $G $D/$F.go && $L $F.$A && ./$A.out // 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 float = iota; g float = 4.5 * iota; ); func main() { if g == 0.0 { print("zero\...
Go
// $G $D/$F.go && $L $F.$A && ./$A.out || echo BUG: should 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" type I interface { send(chan <- int) } type S struct { v int } func ...
Go
// errchk $G $D/$F.go // 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 int64 = 0; println(x != nil); // ERROR "illegal|incompatible|nil" println(0 != nil); // ERROR "illega...
Go
// errchk $G $D/$F.go // 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() { L: ; // ';' terminates empty statement => L does not apply to for loop for i := 0; i < 10; i++ { println...
Go
// $G $D/$F.go || echo BUG should 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() { x := false; func () { if x { println(1); } }(); // this does not compile fun...
Go
// ! $G $D/$F.go // 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; /* bug081.go:3: first constant must evaluate an expression Bus error */
Go
// errchk $G $D/$F.go // 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" } }
Go
// errchk $G $D/$F.go // 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 "sort" func main() { sort.Sort(nil); var x int; sort(x); // ERROR "package" }
Go
// $G $D/bug191.dir/a.go && $G $D/bug191.dir/b.go && $G $D/$F.go && $L $F.$A // 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 . "./a" import . "./b" var _ T var _ V func main() { }
Go
// 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 b func init() { println("b"); } type V int;
Go
// 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 a func init() { println("a"); } type T int;
Go
// $G $D/$F.go || echo BUG: compilation should succeed // 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 = s...
Go
// $G $D/$F.go && $L $F.$A && ./$A.out // 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 ou...
Go
// $G $D/$F.go || echo BUG should 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 myMap map[string] int; func f() myMap { m := make(map[string] int); return m } func main() { ...
Go
// $G $D/$F.dir/bug0.go && $G $D/$F.dir/bug1.go || echo BUG: failed to 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. ignored
Go
// $G $D/$F.go // 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 Scope struct { entries map[string] *Object; } type Type struct { scope *Scope; } type Object struct { typ *Type; } f...
Go
// errchk $G $D/$F.go // 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 { T; // ERROR "embed.*pointer" }
Go
// $G $D/$F.go && $L $F.$A && ./$A.out || echo BUG: bug168 // 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 g byte = 123; var f *byte = &g; var b = make([]byte, 5); func main() { b[0:1][0]...
Go
// 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 x const Zero = 0.0 const Ten = 10.0
Go
// 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" import "./x" func main() { if x.Zero != 0 { println("x.Zero = ", x.Zero); os.Exit(1); } if x.Ten != 10 { println("x.Ten = "...
Go
// $G $D/$F.go && $L $F.$A && ./$A.out // 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 cr...
Go
// errchk $G $D/$F.go // 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); }
Go
// $G $D/$F.go || echo BUG: fails incorrectly // 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(); } /* ue...
Go
// errchk $G $D/$F.go // 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|stupid shift" }
Go
// $G $D/$F.go && $L $F.$A && ./$A.out // 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 { panic(x, " ", ^0) } } /*...
Go
// $G $D/$F.go && $L $F.$A && ./$A.out // 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() { print("ok\n"); c <- 0 } (); <-c }
Go
// $G $D/$F.dir/bug0.go && $G $D/$F.dir/bug1.go && errchk $G $D/$F.dir/bug2.go // 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
Go
// errchk $G $D/$F.go // 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 I interface { m(map[I] bool); // ok } type S struct { m map[S] bool; // ERROR "map key type" }
Go
// $G $D/$F.go && $L $F.$A && ./$A.out // 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],...
Go
// $G $D/$F.go || echo BUG: bug115 should 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 isuint(i uint) { } func main() { i := ^uint(0); isuint(i); }
Go
// $G $D/$F.go && $L $F.$A && ./$A.out // 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; }
Go
// $G $D/$F.go // 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 // Multi-line string literal now allowed. const s = ` Hello, World! ` func main() { print(s) }
Go
// $G $D/$F.go && $L $F.$A && ./$A.out // 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 functio...
Go
// $G $D/$F.go && $L $F.$A || echo BUG: const bug // 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 { panic("a=", a) } }
Go
// $G $D/$F.go && $L $F.$A && ./$A.out // 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() { // This bug doesn't arise with [...]int, or []interface{} or [3]interface{}. ...
Go
// $G $D/$F.go && $L $F.$A && ./$A.out // 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 { ...
Go
// $G $D/$F.go // 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:1...
Go
// errchk $G $D/$F.go // 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 Slice []byte; a := [...]byte{ 0 }; b := Slice(&a); // This should be OK. c := Slice(a); // ERROR "...
Go
// errchk $G $D/$F.go // 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; // ERROR "illegal|inval|shift" x = x >> s; // ERROR "illegal|...
Go
// errchk $G $D/$F.go // 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 x = '''; // ERROR "char"
Go
// $G $D/$F.go && $L $F.$A && ./$A.out || echo BUG: should 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() { switch { // empty switch is allowed according to syntax // u...
Go
// errchk $G $D/$F.go // 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⊛y := 1; // ERROR "identifier" }
Go
// $G $D/$F.go && $L $F.$A && ./$A.out // 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 m...
Go
// $G $D/$F.go && $L $F.$A && ./$A.out // 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() { }
Go
// $G $D/$F.go && $L $F.$A && ./$A.out // 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 = make(chan int); func check(a []int) { for i := 0; i < len(a); i++ { n := <-c; if n != a[i] {...
Go
// $G $D/$F.go && $L $F.$A && ./$A.out // 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. // Repeated malloc test. package main import ( "flag"; "fmt"; "malloc"; "strconv" ) var chatty = flag.Bool("v", f...
Go
// $G $F.go && $L $F.$A && ./$A.out // 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() { print(-(1<<63), "\n"); print((1<<63)-1, "\n") }
Go
// $G $D/$F.go && $L $F.$A && ! ./$A.out // 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 []int; var ia interface{} = a; var m = make(map[interface{}] int); m[ia] = 1; }
Go
// $G $D/$F.go && $L $F.$A && ./$A.out // 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" var call string type T struct { _, _, _ int; } func (T) _() { } func (T) _() { } cons...
Go
// errchk $G -e $D/$F.go // 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. // check for import conflicts package main import "bufio" // GCCGO_ERROR "previous" import bufio "os" // ERROR "redeclared|redefinit...
Go
// $G $F.go || echo BUG: should 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 import os "os"; type t1 int; type t2 int; type t3 int; func f1(t1, t2, t3); func f2(t1, t2, t3 bool); fu...
Go
// $G $F.go && $L $F.$A && ./$A.out // 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 // brainfuck func main() { var a [30000]byte; prog := "++++++++++[>+++++++>++++++++++>+++>+<<<<-]>++.>+.++...
Go
// errchk $G -e $F.go // 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 I interface {} const ( // assume all types behave similarly to int8/uint8 Int8 int8 = 101; Minus1 int8 = -1; Uint8...
Go
// $G $D/$F.go && $L $F.$A && ./$A.out // 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 { a float64; b int64; c string; d byte; } var a = []int{ 1, 2, 3 } var NIL []int; func...
Go
// $G $F.go && $L $F.$A &&./$A.out // 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() { var i uint64 = ' ' + 'a' + 'ä' + '本' + '\a' + '\b' + '\f' + '\n' +...
Go
// $G $F.go && $L $F.$A && ./$A.out // 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() { count := 7; if one := 1; { count = count + one } if count != 8 { print(cou...
Go
// $G $D/$F.go && $L $F.$A && ./$A.out // 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" import "reflect" type S struct { A, B, C, X, Y, Z int; } type T struct { S; } var a1 = S...
Go
// errchk $G -e $D/$F.go // 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 m0 map[string]int var m1 *map[string]int var m2 *map[string]int = &m0 var m3 map[string]int = map[string]int{"a": 1}...
Go
// errchk $G $D/$F.go // 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 int = 1; B byte; // ERROR "type without expr|expected .=." )
Go
// $G $F.go && $L $F.$A && ./$A.out // 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() { for i := 0; i < 1e5; i++ { x := new([100]byte); _ = x; } }
Go
// $G $F.go && $L $F.$A && ./$A.out // 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 assertequal(is, shouldbe int, msg string) { if is != shouldbe { print("assertion fail", msg, "\n"); ...
Go
// errchk $G $D/$F.go // 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 "sync" type T struct { int; sync.Mutex; } func main() { { var x, y sync.Mutex; x = y; // ERROR "assignment....
Go
// errchk $G -e $D/$F.go // 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. // Test that basic operations on named types are valid // and preserve the type. package main type Bool bool type Map map[int]int ...
Go
// $G $D/$F.go && $L $F.$A && ./$A.out // 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 // test range over channels func gen(c chan int, lo, hi int) { for i := lo; i <= hi; i++ { c <- i; } ...
Go
// $G $D/$F.go && $L $F.$A && ./$A.out // 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. // Random malloc test. package main import ( "flag"; "malloc"; "rand"; "unsafe"; ) var chatty = flag.Bool("v", fa...
Go
// $G $F.go && $L $F.$A && ./$A.out // 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 assert(cond bool, msg string) { if !cond { print("assertion fail: ", msg, "\n"); panic(1); } } fu...
Go
// $G $D/$F.go && $L $F.$A && ./$A.out // 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. // A little test program for rational arithmetics. // Computes a Hilbert matrix, its inverse, multiplies them // and ver...
Go
// $G $F.go && $L $F.$A && ./$A.out // 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 "utf8" func main() { var chars [6] int; chars[0] = 'a'; chars[1] = 'b'; chars[2] = 'c'; chars[3]...
Go
// $G $F.go && $L $F.$A && ./$A.out // 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_const = 0 const ( pi = /* the usual */ 3.14159265358979323; e = 2.718281828; mask1 int = 1 << io...
Go
// $G $F.go && $L $F.$A && ./$A.out // 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 nbad int func assert(cond bool, msg string) { if !cond { if nbad == 0 { print("BUG"); } nbad++...
Go