code
stringlengths
10
1.34M
language
stringclasses
1 value
// run // Test for 8g register move bug. The optimizer gets confused // about 16- vs 32-bit moves during splitContractIndex. // Issue 3910. package main func main() { const c = 0x12345678 index, n, offset := splitContractIndex(c) if index != int((c&0xffff)>>5) || n != int(c&(1<<5-1)) || offset != (c>>16)&(1<<14...
Go
// 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" import "strconv" type Test struct { f float64 in string out string } var tests = []Test{ Test{123.5, "123.5", "123.5"...
Go
// 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 s string = nil; // ERROR "illegal|invalid|incompatible|cannot" }
Go
// Copyright 2011 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 import "./a" var Bar = a.Foo
Go
// Copyright 2011 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 type T interface{} func f() T { return nil } var Foo T = f()
Go
// run // Copyright 2010 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. // http://code.google.com/p/go/issues/detail?id=843 package main import "unsafe" type T struct { X, Y uint8 } func main() { var t T if unsafe.Of...
Go
// 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() { // 6g used to compile these as two different // hash codes so it missed the duplication // and worse, compiled the...
Go
// errorcheck // Copyright 2010 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 cases for revised conversion rules. package main func main() { type NewInt int i0 := 0 var i1 int = 1 var i2 NewInt = 1 i0 = i0 i...
Go
// compile // Copyright 2012 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 run 6g out of registers. Issue 2669. package p type y struct { num int } func zzz () { k := make([]byte, 10) arr := make ([]*y...
Go
// 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 { T; // ERROR "embed.*pointer" }
Go
// errorcheck // Copyright 2012 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package p type t struct { x int // ERROR "duplicate field x" x int } func f(t *t) int { return t.x // ERROR "ambiguous selector t.x" }
Go
// 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 v interface{} = 0; switch v.(type) { case int: fallthrough; // ERROR "fallthrough" default: panic("fell t...
Go
// 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 c = 1; func main() { c := 0; _ = c; } /* bug144.go:8: left side of := must be a name bug144.go:8: operation LITERAL not allo...
Go
// 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 foo(a []int) int { return a[0] // this seems to do the wrong thing } func main() { a := &[]int{12} if x := (*a)[0]; x != 12 { p...
Go
// 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...
Go
// 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 ...
Go
// 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 { } // ERROR "return|control" func g() (foo int) { } // ERROR "return|control"
Go
// 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)...
Go
// 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 = +1844...
Go
// errorcheck // Copyright 2011 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. // Issue 2598 package foo return nil // ERROR "non-declaration statement outside function body|expected declaration"
Go
// compile // Copyright 2011 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. // issue 1908 // unreasonable width used to be internal fatal error package test func main() { buf := [1<<30]byte{} _ = buf[:] }
Go
// errorcheck // Copyright 2011 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. // Issue 1411. package main const ui uint = 0 const i int = ui // ERROR "type"
Go
// run // Copyright 2012 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 a = []int64{ 0.0005 * 1e9, 0.001 * 1e9, 0.005 * 1e9, 0.01 * 1e9, 0.05 * 1e9, 0.1 * 1e9, 0.5 * 1e9, 1 * 1e9, 5 ...
Go
// 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:~...
Go
// 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 T1 struct { x, y int } type T2 struct { z, w byte } type T3 T1 type MyInt int func (MyInt) m(*T1) {} func main() { { var i in...
Go
// errorcheck // Copyright 2010 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 U // bogus "invalid recursive type T" from 6g type U int const x T = 123 type V V // ERROR "invalid recursive type"
Go
// errorcheck // Copyright 2011 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 = +"hello" // ERROR "invalid operation.*string|expected numeric" x = +x // ERROR "invalid operation.*...
Go
// run // Copyright 2011 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package main import ( "runtime" "strings" ) var t *struct { c chan int } var c chan int func f() { select { case <-t.c: // THIS IS LINE 22 ...
Go
// 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 ...
Go
// 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 f(a int64) int64 { const b int64 = 0; n := a &^ b; return n; } func main() { f(1) } /* bug156.go:7: constant 18446744073709...
Go
// 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⊛y := 1; // ERROR "identifier" }
Go
// 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 }
Go
// 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 // same const identifier declared twice should not be accepted const none = 0 // GCCGO_ERROR "previous" const none = 1; // ERROR ...
Go
// run // Copyright 2010 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 x = uint32(0x01020304) var y = [...]uint32{1,2,3,4,5} func main() { fmt.Sprint(y[byte(x)]) }
Go
// 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") } } va...
Go
// run // Copyright 2012 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. // Gccgo used to crash compiling this. package main func foo() (int, int) { return 1, 2 } var c = b var a, b = foo() var d = b + 1 func main() { i...
Go
// 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 // Multi-line string literal now allowed. const s = ` Hello, World! ` func main() { print(s) }
Go
// 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. // used to panic because 6g didn't generate // the code to fill in the ... argument to fmt.Sprint. package main import "fmt" type T struct { a, b, c...
Go
// 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 I int type S struct { f map[I]int } var v1 = S{ make(map[int]int) } // ERROR "cannot|illegal|incompatible|wrong" var v2 map[I]...
Go
// 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. // Used to be rejected // http://code.google.com/p/go/issues/detail?id=188 package main func complexSqrt(i int) (int, int) { return 0, 1 } var re...
Go
// 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 var x int var a = []int{ x: 1} // ERROR "constant" var b = [...]int{ x : 1} // ERROR "constant" var c = map[int]int{ x: 1}
Go
// 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; }
Go
// compile // Copyright 2010 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. // Valid program, gccgo reported an error. // bug307.go:14:6: error: complex arguments must have identical types package main func main() { var f...
Go
// 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
Go
// run // Copyright 2011 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. // Issue 2206. Incorrect sign extension of div arguments. package main func five(x int64) { if x != 5 { panic(x) } } func main() { // 5 ...
Go
// errorcheck // Copyright 2012 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package p type T struct { X int } func (t *T) X() {} // ERROR "type T has both field and method named X"
Go
// run // Copyright 2010 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. // http://code.google.com/p/go/issues/detail?id=749 package main func f() (ok bool) { return false } func main() { var i interface{} i = f _ = i....
Go
// 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 "time" func main() { var count int c := make(chan byte) go func(c chan byte) { <-c count++ time.Sleep(1000000) count++ ...
Go
// 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 ...
Go
// run // Copyright 2010 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. // http://code.google.com/p/go/issues/detail?id=662 package main import "fmt" func f() (int, int) { return 1, 2 } func main() { s := fmt.Sprint(f(...
Go
// compile // Copyright 2011 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. // Issue 2674 package main const dow = "\000\003" func main() { println(int(dow[1])) }
Go
// compile // Copyright 2010 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. // Issue 1369. package main const ( c = complex(1, 2) r = real(c) // was: const initializer must be constant i = imag(c) // was: const initiali...
Go
// run // Copyright 2010 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 case for issue 849. package main type I interface { f() } var callee string var error_ bool type T int func (t *T) f() { callee = "f" } f...
Go
// Copyright 2011 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 pkg func NonASCII(b []byte, i int) int { for i = 0; i < len(b); i++ { if b[i] >= 0x80 { break } } return i }
Go
// 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 ...
Go
// errorcheck // Copyright 2011 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 int func main() { (x) := 0 // ERROR "non-name [(]x[)]|non-name on left side" }
Go
// run // Copyright 2011 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 // 5g bug used to set up the 0 for -f() before calling f, // and the call to f smashed the register. func f(n int) int { s := 0 for i ...
Go
// compile // Copyright 2012 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. // gccgo crashed compiling this. package p var v struct{ I } type I interface{}
Go
// 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 x uint; println(1<<x); }
Go
// 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 := make(chan int, 1) c <- 100 x, ok := <-c if x != 100 || !ok { println("x=", x, " ok=", ok, " want 100, true") p...
Go
// 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/...
Go
// 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 "sort" func main() { sort.Sort(nil); var x int; sort(x); // ERROR "package" }
Go
// 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 ...
Go
// 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 I interface{} func foo1(i int) int { return i } func foo2(i int32) int32 { return i } func main() { var i I i = 1 var v1 = i....
Go
// 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" _ = ...
Go
// compile // Copyright 2012 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. // issue 2672 // was trying binary search with an interface type package bug393 func f(x interface{}) int { switch x { case 1: return 1 case...
Go
// 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(a T) T { return a } // ERROR "undefined" func main() { x := f(0); _ = x; }
Go
// errorcheck // Copyright 2011 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. // issue 1979 // used to get internal compiler error too package main import ( "io/ioutil" // GCCGO_ERROR "imported and not used" "net/http"...
Go
// run // Copyright 2010 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 "errors" // Issue 481: closures and var declarations // with multiple variables assigned from one // function call. func main() ...
Go
// run // Copyright 2011 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 := []uint{0} x[0] &^= f() } func f() uint { return 1<<31 // doesn't panic with 1<<31 - 1 }
Go
// compile // Copyright 2010 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. // http://code.google.com/p/go/issues/detail?id=806 // triggered out of registers on 8g package bug283 type Point struct { x int y int } func ...
Go
// compile // Copyright 2012 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. // Issue 2588. Used to trigger internal compiler error on 8g, // because the compiler tried to registerize the int64 being // used as a memory ope...
Go
// run // Copyright 2012 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. // Issue 3899: 8g incorrectly thinks a variable is // "set but not used" and elides an assignment, causing // variables to end up with wrong data. // /...
Go
// compile // Copyright 2011 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. // Issue 1787. package main import "unsafe" const x = unsafe.Sizeof([8]byte{}) func main() { var b [x]int _ = b } /* bug338.go:14: array bou...
Go
// run // Copyright 2012 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 initializing struct fields out of order still runs // functions in the right order. This failed with gccgo. package main type S struct {...
Go
// 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 T // ERROR "recursive"
Go
// compile // Copyright 2011 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. // Issue 1716 package main type ( cplx64 complex64 cplx128 complex128 ) func (c cplx64) Foo() {} func (c cplx128) Foo() {} func main() { v...
Go
// errorcheck // Copyright 2010 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 crash; issue 961. package main type ByteSize float64 const ( _ = iota; // ignore first value by assigning to blank identifier K...
Go
// $G $D/$F.dir/lib.go && $G $D/$F.dir/main.go && $L main.$A && ./$A.out || echo BUG: fails incorrectly // Copyright 2011 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 case for issue 1402. ignored
Go
// 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 func() type I interface { f, g (); // ERROR "name list not allowed" } type J interface { h T; // ERROR "syntax|signatur...
Go
// 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; } fun...
Go
// 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 TStru...
Go
// 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" }
Go
// 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 "reflect" type S1 struct{ i int } type S2 struct{ S1 } func main() { typ := reflect.TypeOf(S2{}) f := typ.Field(0) if f.Name !...
Go
// 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 := make(chan bool, 1); select { case _ = <-c: panic("BUG: recv should not"); default: } c <- true; select { cas...
Go
// errorcheck // Copyright 2011 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. // Issue 2520 package main func main() { if 2e9 { } // ERROR "2e.09|expected bool" if 3.14+1i { } // ERROR "3.14 . 1i|expected bool" }
Go
// 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 big uint64 = 1<<63 func f(a uint64) uint64 { return a << big } func main() { f(1) } /* main·f: doasm: notfound from=75 to=13 ...
Go
// run // Copyright 2011 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. // issue 1808 package main func main() { var i uint64 var x int = 12345 if y := x << (i&5); y != 12345<<0 { println("BUG bug344", y) return ...
Go
// 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); }
Go
// run // Copyright 2010 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 n int func f() int { n++ return n } func main() { x := []int{0,1,2,3,4,5,6,7,8,9,10} n = 5 y := x[f():f()] if len(y) != 1 || ...
Go
// 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 = "\...
Go
// 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() { type Slice []byte; a := [...]byte{ 0 }; b := Slice(a[0:]); // This should be OK. c := Slice(a); // ERROR "invali...
Go
// 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 var t []int var s string; var m map[string]int; func main() { println(t["hi"]); // ERROR "integer" println(s["hi"]); // ERROR "i...
Go
// run // Copyright 2010 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 for issue 778: Map key values that are assignment // compatible with the map key type must be accepted according // to the spec: http://golang....
Go
// 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...
Go
// errorcheck // Copyright 2010 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 *T } func main() { // legal composite literals _ = struct{}{} _ = [42]int{} _ = [...]int{} _ = []int{}...
Go
// run // Copyright 2011 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 "io" func f() (_ string, x float64, err error) { return } func g() (_ string, x float64, err error) { return "hello", 3.14, io...
Go
// $G $D/$F.dir/pkg.go && $G $D/$F.go || echo "Bug 382" // Copyright 2011 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 // Issue 2529 package main import "./pkg" var x = pkg.E var fo = struct {F pkg.T}{F: x}
Go
// compiledir // Copyright 2011 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. // Issue 1705. package ignored
Go
// run // Copyright 2010 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 structures pack densely, according to the alignment of the largest field. package main import ( "fmt" "os" "strconv" ) type T1 struct ...
Go