if !sort.IsSorted(&a) {
panic()
}
- for i, d := range data {
+ for _, d := range data {
fmt.Printf("%s ", d.long_name)
}
fmt.Printf("\n")
{
var x, y sync.Mutex;
x = y; // ERROR "assignment\[ -~\]*Mutex"
+ _ = x;
}
{
var x, y T;
x = y; // ERROR "assignment\[ -~\]*Mutex"
+ _ = x;
}
{
var x, y [2]sync.Mutex;
x = y; // ERROR "assignment\[ -~\]*Mutex"
+ _ = x;
}
{
var x, y [2]T;
x = y; // ERROR "assignment\[ -~\]*Mutex"
+ _ = x;
}
}
fmt.Printf("\n");
<-ref.done;
total := 0;
- for i, c := range cham {
+ for _, c := range cham {
total += c.count;
fmt.Printf("%d %s\n", c.count, say(c.same));
}
// Delete the comment lines and newlines
bytes = compile("(>[^\n]+)?\n").ReplaceAll(bytes, []byte{});
clen := len(bytes);
- for i, s := range variants {
+ for _, s := range variants {
fmt.Printf("%s %d\n", s, countMatches(s, bytes));
}
- for i, sub := range substs {
+ for _, sub := range substs {
bytes = compile(sub.pat).ReplaceAll(bytes, strings.Bytes(sub.repl));
}
fmt.Printf("\n%d\n%d\n%d\n", ilen, clen, len(bytes));
y1 := float(ss);
y2 := float(1<<s); // ERROR "shift"
y3 := string(1<<s); // ERROR "shift"
+ _, _, _, _, _ = s, ss, y1, y2, y3;
}
c <- 0; // ok
ok := c <- 0; // ok
+ _ = ok;
<-c; // ok
x, ok := <-c; // ok
+ _, _ = x, ok;
cr <- 0; // ERROR "send"
ok = cr <- 0; // ERROR "send"
+ _ = ok;
<-cr; // ok
x, ok = <-cr; // ok
+ _, _ = x, ok;
cs <- 0; // ok
ok = cs <- 0; // ok
+ _ = ok;
<-cs; // ERROR "receive"
x, ok = <-cs; // ERROR "receive"
+ _, _ = x, ok;
select {
case c <- 0: // ok
case x := <-c: // ok
+ _ = x;
case cr <- 0: // ERROR "send"
case x := <-cr: // ok
+ _ = x;
case cs <- 0: // ok;
case x := <-cs: // ERROR "receive"
+ _ = x;
}
}
func x() (s string) {
a, b, s := f3();
+ _, _ = a, b;
return // tests that result var is in scope for redeclaration
}
// simple redeclaration
i := f1();
i := f1(); // ERROR "redeclared|no new"
+ _ = i;
}
{
// change of type for f
i, f, s := f3();
f, g, t := f3(); // ERROR "redeclared|cannot assign|incompatible"
+ _, _, _, _, _ = i, f, s, g, t;
}
{
// change of type for i
i, f, s := f3();
j, i, t := f3(); // ERROR "redeclared|cannot assign|incompatible"
+ _, _, _, _, _ = i, f, s, j, t;
}
{
// no new variables
i, f, s := f3();
i, f := f2(); // ERROR "redeclared|no new"
+ _, _, _ = i, f, s;
}
{
// single redeclaration
i, f, s := f3();
i := f1(); // ERROR "redeclared|no new|incompatible"
+ _, _, _ = i, f, s;
}
// double redeclaration
{
i, f, s := f3();
i, f := f2(); // ERROR "redeclared|no new"
+ _, _, _ = i, f, s;
}
{
// triple redeclaration
i, f, s := f3();
i, f, s := f3(); // ERROR "redeclared|no new"
+ _, _, _ = i, f, s;
}
}
func range_escapes(x int) *int {
var a [1]int;
a[0] = x;
- for k, v := range a {
+ for _, v := range a {
return &v;
}
return nil;
var i byte;
i = (*digits)[7]; // compiles
i = digits[7]; // ERROR "illegal|is not|invalid"
+ _ = i;
}
func main() {
func main() {
var x int;
x := 0; // ERROR "declar|:="
+ _ = x;
}
type M map[int] int;
m0 := M{7:8};
+
+ _, _ = t, m0;
}
func main() {
type M map[int] int;
m1 := M{7 : 8};
+ _ = m1;
}
func main() {
a, b := frexp();
+ _, _ = a, b;
}
/*
func main() {
k, l, m := 0,0,0;
+ _, _, _ = k, l, m;
}
mp := &m;
{
- x, ok := m["key"]
+ x, ok := m["key"];
+ _, _ = x, ok;
}
{
- x, ok := (*mp)["key"]
+ x, ok := (*mp)["key"];
+ _, _ = x, ok;
}
{
- x, ok := f()["key"]
+ x, ok := f()["key"];
+ _, _ = x, ok;
}
{
var x int;
a := [...]byte{ 0 };
b := Slice(&a); // This should be OK.
c := Slice(a); // ERROR "invalid|illegal|cannot"
+ _, _ = b, c;
}
func main() {
s := 0;
- for i, v := range []int{1} {
+ for _, v := range []int{1} {
s += v;
}
if s != 1 {
func main() {
var t T = "hello";
println(t[0:4], t[4]);
- for i, x := range t {
+ for _, _ = range t {
}
- for i := range t {
+ for _ = range t {
}
}
func f() {
var x struct { T };
var y struct { T T };
- x = y // ERROR "cannot|incompatible"
+ x = y; // ERROR "cannot|incompatible"
+ _ = x;
}
type T1 struct { T }
func g() {
var x T1;
var y T2;
- x = y // ERROR "cannot|incompatible"
+ x = y; // ERROR "cannot|incompatible"
+ _ = x;
}
func main() {
b := g();
bb, ok := b.(*Buffer);
+ _, _, _ = b, bb, ok;
b, ok = i();
bb, ok = b.(*Buffer);
+ _, _, _ = b, bb, ok;
s := fmt.Sprintf(fmter());
if s != "0x64 \"hello\"" {
s1 := S{a: 7}; // ok - field is named
s3 := S{7, 11}; // ok - all fields have values
s2 := S{7}; // ERROR "too few"
+ _, _, _ = s1, s3, s2;
}
func main() {
{
var i interface{} = new(T1);
- v1, ok1 := i.(*T1);
- v2, ok2 := i.(*T2);
- v3, ok3 := i.(*T3);
+ _, ok1 := i.(*T1);
+ _, ok2 := i.(*T2);
+ _, ok3 := i.(*T3);
if !ok1 || ok2 || ok3 {
panicln("*T1", ok1, ok2, ok3);
}
}
{
var i interface{} = MyInt(0);
- v1, ok1 := i.(interface{ m(*T1) });
- v2, ok2 := i.(interface{ m(*T2) });
- v3, ok3 := i.(interface{ m(*T3) });
+ _, ok1 := i.(interface{ m(*T1) });
+ _, ok2 := i.(interface{ m(*T2) });
+ _, ok3 := i.(interface{ m(*T3) });
if !ok1 || ok2 || ok3 {
panicln("T", ok1, ok2, ok3);
}
func main() {
nchar := 0;
a := []int { '日', '本', '語', 0xFFFD };
- for pos, char := range "日本語\xc0" {
+ for _, char := range "日本語\xc0" {
if nchar >= len(a) {
println("BUG");
break;
func main() {
ok := true;
- for i, s := range same {
+ for _, s := range same {
if !reflect.DeepEqual(s.a, s.b) {
ok = false;
fmt.Printf("not same: %v and %v\n", s.a, s.b);
}
func atoi(s string) int {
- i, xx1 := strconv.Atoi(s);
+ i, _ := strconv.Atoi(s);
return i
}
s := strconv.Itoa(i);
s10 := strconv.Itoa(i*10);
f := float(i);
- t := T{int64(i), f};
// BUG m := M(i, i+1);
if mib[i] != (i != 0) {
fmt.Printf("mib[%d] = %t\n", i, mib[i]);
for i := 0; i < count; i++ {
s := strconv.Itoa(i);
f := float(i);
- t := T{int64(i), f};
{
- a, b := mib[i];
+ _, b := mib[i];
if !b {
fmt.Printf("tuple existence decl: mib[%d]\n", i);
}
- a, b = mib[i];
+ _, b = mib[i];
if !b {
fmt.Printf("tuple existence assign: mib[%d]\n", i);
}
}
{
- a, b := mii[i];
+ _, b := mii[i];
if !b {
fmt.Printf("tuple existence decl: mii[%d]\n", i);
}
- a, b = mii[i];
+ _, b = mii[i];
if !b {
fmt.Printf("tuple existence assign: mii[%d]\n", i);
}
}
{
- a, b := mfi[f];
+ _, b := mfi[f];
if !b {
fmt.Printf("tuple existence decl: mfi[%d]\n", i);
}
- a, b = mfi[f];
+ _, b = mfi[f];
if !b {
fmt.Printf("tuple existence assign: mfi[%d]\n", i);
}
}
{
- a, b := mif[i];
+ _, b := mif[i];
if !b {
fmt.Printf("tuple existence decl: mif[%d]\n", i);
}
- a, b = mif[i];
+ _, b = mif[i];
if !b {
fmt.Printf("tuple existence assign: mif[%d]\n", i);
}
}
{
- a, b := mis[i];
+ _, b := mis[i];
if !b {
fmt.Printf("tuple existence decl: mis[%d]\n", i);
}
- a, b = mis[i];
+ _, b = mis[i];
if !b {
fmt.Printf("tuple existence assign: mis[%d]\n", i);
}
}
{
- a, b := msi[s];
+ _, b := msi[s];
if !b {
fmt.Printf("tuple existence decl: msi[%d]\n", i);
}
- a, b = msi[s];
+ _, b = msi[s];
if !b {
fmt.Printf("tuple existence assign: msi[%d]\n", i);
}
}
{
- a, b := mss[s];
+ _, b := mss[s];
if !b {
fmt.Printf("tuple existence decl: mss[%d]\n", i);
}
- a, b = mss[s];
+ _, b = mss[s];
if !b {
fmt.Printf("tuple existence assign: mss[%d]\n", i);
}
}
{
- a, b := mspa[s];
+ _, b := mspa[s];
if !b {
fmt.Printf("tuple existence decl: mspa[%d]\n", i);
}
- a, b = mspa[s];
+ _, b = mspa[s];
if !b {
fmt.Printf("tuple existence assign: mspa[%d]\n", i);
}
}
{
- a, b := mipT[i];
+ _, b := mipT[i];
if !b {
fmt.Printf("tuple existence decl: mipT[%d]\n", i);
}
- a, b = mipT[i];
+ _, b = mipT[i];
if !b {
fmt.Printf("tuple existence assign: mipT[%d]\n", i);
}
}
{
- a, b := mpTi[apT[i]];
+ _, b := mpTi[apT[i]];
if !b {
fmt.Printf("tuple existence decl: mpTi[apT[%d]]\n", i);
}
- a, b = mpTi[apT[i]];
+ _, b = mpTi[apT[i]];
if !b {
fmt.Printf("tuple existence assign: mpTi[apT[%d]]\n", i);
}
}
{
- a, b := mipM[i];
+ _, b := mipM[i];
if !b {
fmt.Printf("tuple existence decl: mipM[%d]\n", i);
}
- a, b = mipM[i];
+ _, b = mipM[i];
if !b {
fmt.Printf("tuple existence assign: mipM[%d]\n", i);
}
}
{
- a, b := mit[i];
+ _, b := mit[i];
if !b {
fmt.Printf("tuple existence decl: mit[%d]\n", i);
}
- a, b = mit[i];
+ _, b = mit[i];
if !b {
fmt.Printf("tuple existence assign: mit[%d]\n", i);
}
}
// {
-// a, b := mti[t];
+// _, b := mti[t];
// if !b {
// fmt.Printf("tuple existence decl: mti[%d]\n", i);
// }
-// a, b = mti[t];
+// _, b = mti[t];
// if !b {
// fmt.Printf("tuple existence assign: mti[%d]\n", i);
// }
for i := count; i < 2*count; i++ {
s := strconv.Itoa(i);
f := float(i);
- t := T{int64(i),f};
{
- a, b := mib[i];
+ _, b := mib[i];
if b {
fmt.Printf("tuple nonexistence decl: mib[%d]", i);
}
- a, b = mib[i];
+ _, b = mib[i];
if b {
fmt.Printf("tuple nonexistence assign: mib[%d]", i);
}
}
{
- a, b := mii[i];
+ _, b := mii[i];
if b {
fmt.Printf("tuple nonexistence decl: mii[%d]", i);
}
- a, b = mii[i];
+ _, b = mii[i];
if b {
fmt.Printf("tuple nonexistence assign: mii[%d]", i);
}
}
{
- a, b := mfi[f];
+ _, b := mfi[f];
if b {
fmt.Printf("tuple nonexistence decl: mfi[%d]", i);
}
- a, b = mfi[f];
+ _, b = mfi[f];
if b {
fmt.Printf("tuple nonexistence assign: mfi[%d]", i);
}
}
{
- a, b := mif[i];
+ _, b := mif[i];
if b {
fmt.Printf("tuple nonexistence decl: mif[%d]", i);
}
- a, b = mif[i];
+ _, b = mif[i];
if b {
fmt.Printf("tuple nonexistence assign: mif[%d]", i);
}
}
{
- a, b := mis[i];
+ _, b := mis[i];
if b {
fmt.Printf("tuple nonexistence decl: mis[%d]", i);
}
- a, b = mis[i];
+ _, b = mis[i];
if b {
fmt.Printf("tuple nonexistence assign: mis[%d]", i);
}
}
{
- a, b := msi[s];
+ _, b := msi[s];
if b {
fmt.Printf("tuple nonexistence decl: msi[%d]", i);
}
- a, b = msi[s];
+ _, b = msi[s];
if b {
fmt.Printf("tuple nonexistence assign: msi[%d]", i);
}
}
{
- a, b := mss[s];
+ _, b := mss[s];
if b {
fmt.Printf("tuple nonexistence decl: mss[%d]", i);
}
- a, b = mss[s];
+ _, b = mss[s];
if b {
fmt.Printf("tuple nonexistence assign: mss[%d]", i);
}
}
{
- a, b := mspa[s];
+ _, b := mspa[s];
if b {
fmt.Printf("tuple nonexistence decl: mspa[%d]", i);
}
- a, b = mspa[s];
+ _, b = mspa[s];
if b {
fmt.Printf("tuple nonexistence assign: mspa[%d]", i);
}
}
{
- a, b := mipT[i];
+ _, b := mipT[i];
if b {
fmt.Printf("tuple nonexistence decl: mipT[%d]", i);
}
- a, b = mipT[i];
+ _, b = mipT[i];
if b {
fmt.Printf("tuple nonexistence assign: mipT[%d]", i);
}
}
{
- a, b := mpTi[apT[i]];
+ _, b := mpTi[apT[i]];
if b {
fmt.Printf("tuple nonexistence decl: mpTi[apt[%d]]", i);
}
- a, b = mpTi[apT[i]];
+ _, b = mpTi[apT[i]];
if b {
fmt.Printf("tuple nonexistence assign: mpTi[apT[%d]]", i);
}
}
{
- a, b := mipM[i];
+ _, b := mipM[i];
if b {
fmt.Printf("tuple nonexistence decl: mipM[%d]", i);
}
- a, b = mipM[i];
+ _, b = mipM[i];
if b {
fmt.Printf("tuple nonexistence assign: mipM[%d]", i);
}
}
// {
-// a, b := mti[t];
+// _, b := mti[t];
// if b {
// fmt.Printf("tuple nonexistence decl: mti[%d]", i);
// }
-// a, b = mti[t];
+// _, b = mti[t];
// if b {
// fmt.Printf("tuple nonexistence assign: mti[%d]", i);
// }
// }
{
- a, b := mit[i];
+ _, b := mit[i];
if b {
fmt.Printf("tuple nonexistence decl: mit[%d]", i);
}
- a, b = mit[i];
+ _, b = mit[i];
if b {
fmt.Printf("tuple nonexistence assign: mit[%d]", i);
}
fmt.Printf("update mipM[%d][%d] = %i\n", i, i, mipM[i][i]);
}
}
-
+
// test range on nil map
var mnil map[string] int;
- for x, y := range mnil {
+ for _, _ = range mnil {
panic("range mnil");
}
}
func testarray() {
s := 0;
- for k, v := range makearray() {
+ for _, v := range makearray() {
s += v;
}
if nmake != 1 {
func (arr IntArray) Iter() <-chan interface {} {
ch := make(chan interface {});
go func() {
- for i, x := range arr {
+ for _, x := range arr {
ch <- x
}
close(ch)