code
stringlengths
10
1.34M
language
stringclasses
1 value
// runoutput // 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 source files and strings containing \r and \r\n. package main import ( "fmt" "strings" ) func main() { prog = strings.Replace(prog, ...
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. // Verify that pointers and interface types cannot be method receivers. // Does not compile. package main type T struct { a int } type P *T ty...
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. // Verify that erroneous initialization expressions are caught by the compiler // Does not compile. package main type S struct { A, B, C, X, 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. // Verify that it is illegal to take the address of a function. // Does not compile. package main var notmain func() func main() { var x = &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. // Test floating-point literal syntax. package main var bad bool func pow10(pow int) float64 { if pow < 0 { return 1 / pow10(-pow) } if pow > 0 ...
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 ( "fmt" "runtime" "time" ) type Number struct { next *Number } // ------------------------------------- // Peano primitives ...
Go
/* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form ...
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 main import ( "flag" "fmt" "log" "os" "runtime" "runtime/pprof" "time" "unsafe" ) const BranchingFactor = 4 type Object struct { child [Bra...
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. // Garbage collection benchmark: parse Go packages repeatedly. package main import ( "flag" "fmt" "go/ast" "go/parser" "go/token" "log" "net/http" _ ...
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 main import ( "fmt" "runtime" "sort" "time" ) func gcstats(name string, n int, t time.Duration) { st := new(runtime.MemStats) runtime.ReadMemSt...
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. // Test that types can be parenthesized. package main func f(interface{}) func g() {} func main() { f(map[string]string{"a":"b","c":"d"}) f([......
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. // Test that goroutines and garbage collection run during init. package main import "runtime" var x []byte func init() { c := make(chan int) go s...
Go
// errchk -0 $G -m $D/$F.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. // Test, using compiler diagnostic flags, that the escape analysis is working. // Compiles but does not run. Inlining is enabled....
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. // Verify that incorrect comparisons are detected. // Does not compile. package main func use(bool) {} type T1 *int type T2 *int type T3 stru...
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 line numbers in error messages. // Does not compile. package main var ( _ = x // ERROR "undefined.*x" _ = x // ERROR "undefined.*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. // Verify overflow is detected when using numeric constants. // Does not compile. package main type I interface{} const ( // assume all types...
Go
// errchk -0 $G -m -l $D/$F.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. // Test, using compiler diagnostic flags, that the escape analysis is working. // Compiles but does not run. Inlining is disab...
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 when the compiler expands append inline it does not // overwrite a value before it needs it (issue 3369). package main func main() { s ...
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 p func f() (_ int, err error) { return } func g() (x int, _ error) { return } func h() (_ int, _ error) { return } func i() (int,...
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 file. package p var V = "a" > "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 int func f() { var x struct { T }; var y struct { T T }; x = y; // ERROR "cannot|incompatible" _ = x; } type T1 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. // Used to crash // http://code.google.com/p/go/issues/detail?id=204 package main func () x() // ERROR "no receiver" func (a b, c d) x() // ER...
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 T1 struct { Next *T2 } type T2 T1 type T3 struct { Next *T4 } type T4 T5 type T5 T6 type T6 T7 type T7 T8 type T8 T9 type T9 T3...
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 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
// 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 type I interface { m(a, b, c, d, e, f, g, h byte) } type Int8 int8 func (x Int8) m(a, b, c, d, e, f, g, h byte) { check("Int8", int64...
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() /* no return type */ {} func main() { x := f(); // ERROR "mismatch|as value|no 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 ncall int; type Iffy interface { Me() Iffy } type Stucky struct { n int } func (s *Stucky) Me() Iffy { ncall++; return s } 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 func main() { x := 0 x = ^x // unary ^ not yet implemented if x != ^0 { println(x, " ", ^0) panic("fail") } } /* uetli:~/Source/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. // Troublesome floating point constants. Issue 1463. package main import "fmt" func check(test string, got, want float64) bool { if got != want { ...
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 1709 package main func main() { type Ts string var ts Ts _ = []byte(ts) } /* bug333.go:14: cannot use ts (type Ts) as ...
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 type T *T func f(t T) { println(t, *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 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
// 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. // gc used to overflow a counter when a variable was // mentioned 256 times, and generate stack corruption. package main func main() { F(1) } func F...
Go
// compiledir // 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
// 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...
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 frexp() (a int, b float64) { return 1, 2.0 } func main() { a, b := frexp(); _, _ = a, b; } /* bug056.go:8: illegal types for ope...
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. package ignored
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 A []int; func main() { a := &A{0}; b := &A{0, 1}; _, _ = a, b; } /* uetli:~/Source/go1/test/bugs gri$ 6g bug096.go && 6l bug...
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. // https://code.google.com/p/gofrontend/issues/detail?id=1 package main func f1() { a, b := f() // ERROR "mismatch|does not match" _ = a _ ...
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 "fmt" var indent uint = 10 func main() { const dots = ". . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . " + ". ...
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() { bad := false if (-5 >> 1) != -3 { println("-5>>1 =", -5>>1, "want -3") bad = true } if (-4 >> 1) != -2 { println("...
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
// 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=920 package main type X struct { x []X } func main() { type Y struct { x []Y } // used to get inval...
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 1608. // Size used to be -1000000000. package main import "unsafe" func main() { var a interface{} = 0 size := unsafe.Sizeof(a) if size ...
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 main // Check that the export information is correct in p.6. import _ "./p" // Check that it's still correct in pp.a (which contains p.6). import _ "...
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 p type T struct { x1 int x2 int x3 int x4 int x5 int x6 int x7 int x8 int x9 int x10 int x11 int x12 int x13 int x14 int x15 int x16 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 type myMap map[string] int; func f() myMap { m := make(map[string] int); return m } func main() { m := make(myMap); mp := &m; ...
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. // Was failing to compile with 'invalid receiver' due to // incomplete type definition evaluation. Issue 3709. package p type T1 struct { F *T2 ...
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. // Some indirect uses of types crashed gccgo, because it assumed that // the size of the type was known before it had been computed. package p typ...
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 2009 The Go Authors. All 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 { f int; } // 6g used to get confused by the f:1 above // and allow uses of f that would be silently // dropped dur...
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 "fmt" var s string func accum(args ...interface{}) { s += fmt.Sprintln(args...) } func f(){ v := 0.0 for i := 0; i < 3; 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. // http://code.google.com/p/go/issues/detail?id=799 package main import "unsafe" func main() { n := unsafe.Sizeof(0) if n != 4 && n != 8 { print...
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 := uint(10) ss := 1 << s y1 := float64(ss) y2 := float64(1 << s) // ERROR "shift" y3 := string(1 << s) // ERR...
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. // Used to call wrong methods; issue 1290. package main type S struct { } func (S) a() int{ return 0 } func (S) b() int{ return 1 } func main() { ...
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 2009 The Go Authors. All 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 := []rune{'日', '本', '語', 0xFFFD} for _, char := range "日本語\xc0" { if nchar >= len(a) { println("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=915 package main type T struct { x int } var t = &T{42} var i interface{} = t var tt, ok = i.(*T) ...
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. // Was discarding function calls made for arguments named _ // in inlined functions. Issue 3593. package main var did int func main() { foo(side()...
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
// Copyright 2009 The Go Authors. 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);
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 P "./bug0" func main() { a0 := P.V0(); // works a1 := P.V1(); // works a2, b2 := P.V2(); // doesn't work _, _, _, _ = a0, a1, a2, ...
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 len int; // len should not be a keyword - this doesn't compile _ = len; }
Go
// $G $D/$F.dir/one.go && $G $D/$F.dir/two.go && $G $D/$F.go && $L $F.$A && ./$A.out // 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 converting a type defined in a different package to an // interfa...
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() { const ( Delta = 100 * 1e6 Count = 10 ) _ = int64(Delta * Count) var i interface{} = Count j := i.(int) if j != Co...
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
// cmpout // 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 p unsafe.Pointer println(p) }
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 one func Foo() (n int64, _ *int) { return 42, nil }
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 two import _ "./one"
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
// 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 v1 = T1(1) var v2 = T2{2} var v3 = T3{0: 3, 1: 4} var v4 = T4{0: 5, 1: 6} var v5 = T5{0: 7, 1: 8} var v6 = T2{f: 9} var v7 = T4{f: 10}...
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 func f(args ...int) { g(args) } func g(args ...interface{}) { f(args) // ERROR "cannot use|incompatible" }
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 { x, x int // ERROR "duplicate" }
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 atom(s string) { if s == nil { // ERROR "nil|incompatible" return; } } func main() {} /* bug047.go:4: fatal error: strin...
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 2009 The Go Authors. All 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 :=...
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 2355 package main type T struct {} func (T) m() string { return "T" } type TT struct { T m func() string } func ff() string { return "ff...
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
// 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
// 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 3843: inlining bug due to wrong receive operator precedence. package pkg2 import "./pkg1" func F() { pkg1.Do() }
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 pkg1 var x = make(chan interface{}) func Do() int { return (<-x).(int) }
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 ( "./p" ) type T struct{ *p.S } type I interface { get() } func main() { var t T p.F(t) var x interface{} = t _, ok := x.(I) if ok ...
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 p type T struct{ x int } type S struct{} func (p *S) get() { } type I interface { get() } func F(i I) { i.get() }
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 nf int var ng int func f() (int, int, int) { nf++ return 1, 2, 3 } func g() int { ng++ return 4 } var x, y, z = f() var m = mak...
Go
// $G $D/$F.dir/p1.go && $G $D/$F.dir/main.go && $L main.$A && ./$A.out // 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 ignored
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 { 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
// 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 */
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 "testing" func main() { var t testing.T // make sure error mentions that // name is unexported, not just "name not fo...
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 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 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 I1 interface { I2 } // ERROR "interface" type I2 int type I3 interface { int } // ERROR "interface" type S struct { x inter...
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 S struct { a int } type PS *S func (p *S) get() int { return p.a } func fn(p PS) int { // p has type PS, and PS has no me...
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
// 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 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. func main() { // 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 func main() { Foo: { return; } goto Foo; } /* bug5.go:4: Foo undefined bug5.go:4: fatal error: walktype: switch 1 unknown op GOTO l(4...
Go