code
stringlengths
10
1.34M
language
stringclasses
1 value
// 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.ne...
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() { c := make(chan int, 1) dummy := make(chan int) v := 0x12345678 for i := 0; i < 10; i++ { // 6g had a bug that caused ...
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() { x := 0; // this compiles switch x { case 0: } // this doesn't but should switch 0 { case 0: } } /* bug158.g...
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
// 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) ...
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=990 package main func main() { defer func() { if recover() != nil { panic("non-nil recover"...
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
// 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 < 10; i++ { print(i) break L4...
Go
// $G $D/$F.dir/bug0.go && // $G $D/$F.dir/bug1.go && // $G $D/$F.dir/bug2.go && // errchk $G -e $D/$F.dir/bug3.go && // $L bug2.$A && // ./$A.out || 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 ...
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 exit int exit: _ = exit goto exit }
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
// 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...
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 ddd func Sum() int for i := range []int{} { return i } // ERROR "statement outside function|expected"
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" type I interface { send(chan <- int) } type S struct { v int } func (p *S) send(c chan <- int) { c <- p.v } func main() { ...
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 2451, 2452 package foo func f() error { return 0 } // ERROR "cannot use 0 .type int.|has no methods" func g() error { return -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. package main func main() { var x int64 = 0; println(x != nil); // ERROR "illegal|incompatible|nil" println(0 != nil); // ERROR "illegal|incomp...
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() { L: ; // ';' terminates empty statement => L does not apply to for loop for i := 0; i < 10; i++ { println(i); b...
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() { x := false; func () { if x { println(1); } }(); // this does not compile func () { if x == false { println(...
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 const x x = 2 // ERROR "loop|type" /* bug081.go:3: first constant must evaluate an expression Bus error */
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 i33 int64; if i33 == (1<<64) -1 { // ERROR "overflow" } }
Go
// $G $D/$F.dir/p1.go && $G $D/$F.dir/p2.go // 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. 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 import "sort" func main() { sort.Sort(nil); var x int; sort(x); // ERROR "package" }
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
// 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. // Conversion between identical interfaces. // Issue 1647. // The compiler used to not realize this was a no-op, // so it generated a call to the non-...
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
// 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 1136 package main import "fmt" func log1(f string, argv ...interface{}) { fmt.Printf("log: %s\n", fmt.Sprintf(f, argv...)) } func mai...
Go
// 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 p1 type T struct { f func() "x" }
Go
// 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 p2 import _ "./p1"
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
// 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 { pa...
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 x int; switch x { case 0: {} case 1: x = 0; } } /* bug0.go:8: case statement out of place */
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 1811. // gccgo failed to compile this. package p type E interface{} type I interface { E E }
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 gen = 'a' func f(n int) string { s := string(gen) + string(n+'A'-1) gen++ return s } func g(x, y string) string { return x + y }...
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 type myMap map[string] int; func f() myMap { m := make(map[string] int); return m } func main() { m := make(myMap); mp := &m; ...
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
// $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
// 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 // issue 2337 // The program deadlocked. import "runtime" func main() { runtime.GOMAXPROCS(2) runtime.GC() runtime.GOMAXPROCS(1) }
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
// 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. package bug267 type T []int var a []bool func _() { if a[T{42}[0]] { } // if (a[T{42}[0]]) {} // this compiles } /* 6g bugs/bug267.go bugs/b...
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 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 c1 chan <- chan int = (chan<- (chan int))(nil) var c2 chan <- chan int = (chan (<-chan int))(nil) // ERROR "chan|incompatible...
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 g byte = 123 var f *byte = &g var b = make([]byte, 5) func main() { b[0:1][0] = *f if b[0] != 123 { println("want 123 got", b[0])...
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
// 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 func f() int { defer func() { recover() }() panic("oops") } func g() int { return 12345 } func main() { g() // leave 12345 on s...
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
// 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 die dividing by zero; issue 879. package main var mult [3][...]byte = [3][5]byte{} // ERROR "\.\.\."
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 a [1000] int64; // this alone works var b [10000] int64; // this causes a runtime crash _, _ = a, b; } /* uetli:~/...
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
// 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 import "unsafe" func main() { var x unsafe.Pointer println(*x) // ERROR "invalid indirect.*unsafe.Pointer" var _ = (unsafe.Poi...
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
// 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 func main() { data := make(map[int]string, 1) data[0] = "hello, " data[0] += "world!" if data[0] != "hello, world!" { panic("BUG: " ...
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. // Issue 1927. // gccgo failed to issue the first error below. package main func main() { println(int(1) == uint(1)) // ERROR "types" var x i...
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
// 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|stupid shift" _ = v }
Go
// $G $D/$F.dir/p.go && $G $D/$F.dir/main.go // 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 2716. Export metadata error made main.go not compile. package ignored
Go
// [ $A == 6 ] || errchk $G -e $D/$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. // Issue 2444 package main func main() { var arr [1000200030]int // ERROR "type .* too large" arr_bkup := arr _ ...
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
// 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 1757. // gccgo failed to compile this. package main func main() { (_) = 0 }
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 type Value struct { X interface{} Y int } type Struct struct { X complex128 } const magic = 1 + 2i func (Value) Complex(x complex12...
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() { x := 0 x = ^x // unary ^ not yet implemented if x != ^0 { println(x, " ", ^0) panic("fail") } } /* uetli:~/Source/g...
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. // http://code.google.com/p/go/issues/detail?id=3119 package main import "fmt" func main() { s := "hello" fmt.Println(s == "") fmt.Println(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. package main var c chan int func main() { c = make(chan int); go func() { c <- 0 } (); <-c }
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
// 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 var a [10]int // ok var b [1e1]int // ok var c [1.5]int // ERROR "truncated" var d ["abc"]int // ERROR "invalid array bound|not nu...
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 bug233 import p "fmt" var _ = p.Print var fmt = 10
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 1664 package main func main() { var i uint = 33 var a = (1<<i) + 4.5 // ERROR "shift of type float64|invalid.*shift" println(a) ...
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
// 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 interface { m(map[I] bool); // ok } type S struct { m map[S] bool; // ERROR "map key type" }
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
// 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 2343 package main type T struct {} func (t *T) pm() {} func (t T) m() {} func main() { p := &T{} p.pm() p.m() q := &p q.m() ...
Go
// $G $D/$F.dir/one.go && $G $D/$F.dir/two.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 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 2497 package main type Header struct{} func (h Header) Method() {} var _ interface{} = Header{} func main() { type X Header var _ in...
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 main import ( "bufio" "./io" goio "io" ) func main() { // The errors here complain that io.X != io.X // for different values of io so they shoul...
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 io type Writer interface { WrongWrite() } type SectionReader struct { X int } func SR(*SectionReader) {}
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 isuint(i uint) { } func main() { i := ^uint(0); isuint(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 func main() { type M map[int] int; m1 := M{7 : 8}; _ = m1; }
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. 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: err...
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 main import "./lib" type I interface { M() } type PI interface { PM() } func main() { var t lib.T t.M() t.PM() // This is still an error. //...
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 lib type T struct { x int // non-exported field } func (t T) M() { } func (t *T) PM() { }
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 func main() { m := make(map[string][1000]byte) m["hi"] = [1000]byte{1} v := m["hi"] for k, vv := range m { if k != "hi" || stri...
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 a = 0 func f() { const a = 5 } func main() { if a != 0 { println("a=", a) panic("fail") } }
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" func main() { // This bug doesn't arise with [...]int, or []interface{} or [3]interface{}. a := [...]interface{} { 1, 2, 3 ...
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 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=808 package main type A [...]int // ERROR "outside of array literal"
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 type I1 interface {} type I2 interface { pr() } func e() I1; var i1 I1; var i2 I2; func main() { i2 = e().(I2); // bug089.go:16: ...
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 func main() { var s int = 0; var x int = 0; x = x << s; // ERROR "illegal|inval|shift" x = x >> s; // ERROR "illegal|inval|sh...
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 const ( joao = "João" jose = "José" ) func main() { s1 := joao s2 := jose if (s1 < s2) != (joao < jose) { panic("unequal") } }
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 = '''; // ERROR "char"
Go
// 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 one // Issue 2877 type T struct { f func(t *T, arg int) g func(t T, arg int) } func (t *T) foo(arg int) {} func (t T) goo(arg int) {} func (t *T) ...
Go
// 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. // Use the functions in one.go so that the inlined // forms get type-checked. package two import "./one" func use() { var r one.T r.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 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 1662 // iota inside var package main var ( a = iota // ERROR "undefined: iota|iota is only defined in const" b = iota // ERROR "u...
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() { switch { // empty switch is allowed according to syntax // unclear why it shouldn't be allowed } switch tag := 0; tag ...
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
// $G $D/bug302.dir/p.go && pack grc pp.a p.$A && $G $D/bug302.dir/main.go // 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.
Go