]> Cypherpunks.ru repositories - gostls13.git/commitdiff
fix "declared and not used" in tests;
authorRuss Cox <rsc@golang.org>
Tue, 15 Sep 2009 04:03:53 +0000 (21:03 -0700)
committerRuss Cox <rsc@golang.org>
Tue, 15 Sep 2009 04:03:53 +0000 (21:03 -0700)
also template/template.go, missed last time.

R=r
DELTA=116  (61 added, 10 deleted, 45 changed)
OCL=34620
CL=34622

57 files changed:
src/pkg/template/template.go
test/235.go
test/bigalg.go
test/bugs/bug196.go
test/complit.go
test/decl.go
test/fixedbugs/bug008.go
test/fixedbugs/bug009.go
test/fixedbugs/bug011.go
test/fixedbugs/bug012.go
test/fixedbugs/bug013.go
test/fixedbugs/bug017.go
test/fixedbugs/bug023.go
test/fixedbugs/bug024.go
test/fixedbugs/bug031.go
test/fixedbugs/bug053.go
test/fixedbugs/bug055.go
test/fixedbugs/bug057.go
test/fixedbugs/bug061.go
test/fixedbugs/bug069.go
test/fixedbugs/bug070.go
test/fixedbugs/bug071.go
test/fixedbugs/bug075.go
test/fixedbugs/bug077.go
test/fixedbugs/bug084.go
test/fixedbugs/bug087.go
test/fixedbugs/bug088.dir/bug1.go
test/fixedbugs/bug092.go
test/fixedbugs/bug094.go
test/fixedbugs/bug096.go
test/fixedbugs/bug098.go
test/fixedbugs/bug129.go
test/fixedbugs/bug135.go
test/fixedbugs/bug143.go
test/fixedbugs/bug144.go
test/fixedbugs/bug145.go
test/fixedbugs/bug154.go
test/fixedbugs/bug179.go
test/fixedbugs/bug187.go
test/fixedbugs/bug202.go
test/gc.go
test/gc1.go
test/hashmap.go
test/if.go
test/interface/convert.go
test/interface/fail.go
test/interface/pointer.go
test/interface/receiver1.go
test/ken/rob2.go
test/ken/robif.go
test/ken/simpvar.go
test/literal.go
test/method.go
test/nil.go
test/stringrange.go
test/switch.go
test/test0.go

index 46003b7671ab66c7d6367717829f9f24d1f6f523..4d77a541709b7c267158d507f1ac3096042436c9 100644 (file)
@@ -397,12 +397,12 @@ func (t *Template) newVariable(name_formatter string) (v *variableElement) {
 
        // Is it in user-supplied map?
        if t.fmap != nil {
-               if fn, ok := t.fmap[formatter]; ok {
+               if _, ok := t.fmap[formatter]; ok {
                        return
                }
        }
        // Is it in builtin map?
-       if fn, ok := builtins[formatter]; ok {
+       if _, ok := builtins[formatter]; ok {
                return
        }
        t.parseError("unknown formatter: %s", formatter);
@@ -631,17 +631,17 @@ func (t *Template) writeVariable(v *variableElement, st *state) {
        val := t.varValue(v.name, st).Interface();
        // is it in user-supplied map?
        if t.fmap != nil {
-               if fn, ok := t.fmap[v.formatter]; ok {
-                       fn(st.wr, val, v.formatter);
+               if fn, ok := t.fmap[formatter]; ok {
+                       fn(st.wr, val, formatter);
                        return;
                }
        }
        // is it in builtin map?
-       if fn, ok := builtins[v.formatter]; ok {
-               fn(st.wr, val, v.formatter);
+       if fn, ok := builtins[formatter]; ok {
+               fn(st.wr, val, formatter);
                return;
        }
-       t.execError(st, v.linenum, "missing formatter %s for variable %s", v.formatter, v.name)
+       t.execError(st, v.linenum, "missing formatter %s for variable %s", formatter, v.name)
 }
 
 // Execute element i.  Return next index to execute.
@@ -796,7 +796,7 @@ func validDelim(d []byte) bool {
        if len(d) == 0 {
                return false
        }
-       for i, c := range d {
+       for _, c := range d {
                if white(c) {
                        return false
                }
index fe3024c613964aec035b5b718d5d9630b88b5440..7507a3ef56f0c4b610f4ad8f4052204f94103a97 100644 (file)
@@ -53,7 +53,6 @@ func main() {
        }
 
        for i := 0; i < len(OUT); i++ {
-               t := min(xs);
                for i := 0; i < n; i++ {
                        ins[i] <- x;
                }
index dba8cc4dd15fca882056a7ac149aed384be331e4..89ece01b98bbd8d55b581fc707c9b5bd626c8052 100644 (file)
@@ -22,7 +22,6 @@ var a = []int{ 1, 2, 3 }
 var NIL []int;
 
 func arraycmptest() {
-       a1 := a;
        if NIL != nil {
                println("fail1:", NIL, "!= nil");
        }
@@ -112,6 +111,7 @@ func interfacetest() {
        i = e;
        e1 := i.(E);
        // nothing to check; just verify it doesn't crash
+       _ = e1;
 }
 
 func main() {
index 0aa055010a741c4192e671914fa94562108e9f17..b903079508f059c74195a7f19b7b1c1fecdea6dd 100644 (file)
@@ -26,6 +26,8 @@ func xxx() {
        xx, ok = i.(int);
 
        a,b := multi();
+
+       _, _, _, _, _ = x, ok, xx, a, b;
 }
 
 func f() map[int]int {
index d9b94885195cfa1c5901b2272202e1827a2d0a53..3d5a684693a6c90745736982d02b4d81817dc371 100644 (file)
@@ -46,7 +46,7 @@ func main() {
        oai = []int{1,2,3};
        if len(oai) != 3 { panic("oai") }
 
-       at := [...]*T{&t, &t, &t};
+       at := [...]*T{&t, tp, &t};
        if len(at) != 3 { panic("at") }
 
        c := make(chan int);
index c2919d32b0fab56c1155ff1e69da53bc0c03ace4..273d0ecffc10ea0f78bf30d51aa8fd942021d50f 100644 (file)
@@ -30,8 +30,10 @@ func main() {
                k := f1();
                m, g, s := f3();
                m, h, s := f3();
+               _, _, _, _, _, _, _, _, _ = i, f, s, j, k, m, g, s, h;
        }
        if x() != "3" {
                println("x() failed");
        }
+       _, _, _, _, _, _, _, _, _ = i, f, s, j, k, m, g, s, h;
 }
index 7e7c5ca796a2d84c373f210fb3b4c4c21021497f..2baead11e36e838e4e52b83fa9612a5e435e5e9b 100644 (file)
@@ -10,9 +10,9 @@ func main() {
        i5 := 5;
 
        switch {  // compiler crash fixable with 'switch true'
-       case i5 < 5: dummy := 0;
-       case i5 == 5: dummy := 0;
-       case i5 > 5: dummy := 0;
+       case i5 < 5: dummy := 0; _ = dummy;
+       case i5 == 5: dummy := 0; _ = dummy;
+       case i5 > 5: dummy := 0; _ = dummy;
        }
 }
 /*
index f52cd84daaffe2c1f4b29377ba26e136e7671701..ef8263bb24057f18c0db31d36b6c2f346fcb2315 100644 (file)
@@ -8,7 +8,7 @@ package main
 
 
 func main() {
-       fired := false;
+       fired := false; _ = fired;
 }
 /*
 bug9.go:5: defaultlit: unknown literal: LITERAL-B0 a(1)
index 63673c0865ddca8e80229c3cb1eaac6dd3c150be..551adb77dfc84eee21941cee303192a4815b5602 100644 (file)
@@ -20,6 +20,7 @@ func main() {
        t.x = 1;
        t.y = 2;
        r10 := t.m(1, 3.0);
+       _ = r10;
 }
 /*
 bug11.go:16: fatal error: walktype: switch 1 unknown op CALLMETH l(16) <int32>INT32
index 41d1bf627bae7c434151ca461f2965d884bbb366..ffd5b55706591a11e8b68479edc56d9fd609eec2 100644 (file)
@@ -10,6 +10,7 @@ package main
 func main() {
        var u30 uint64 = 0;
        var u31 uint64 = 1;
+       _, _ = u30, u31;
        var u32 uint64 = 18446744073709551615;
        var u33 uint64 = +18446744073709551615;
        if u32 != (1<<64)-1 { panic("u32\n"); }
index 33b532b2a3b234e7d1b86c7644cfdc8077a8ed74..4b106775c28bb84b4c8982d102f1a2bfc40348a9 100644 (file)
@@ -9,6 +9,7 @@ package main
 func main() {
        var cu0 uint16 = '\u1234';
        var cU1 uint32 = '\U00101234';
+       _, _ = cu0, cU1;
 }
 /*
 bug13.go:4: missing '
index eedc6d7e23b23fc468cab7c75f19d753f401074d..fdc986d9def30efc28654091ce1f9288f18e2977 100644 (file)
@@ -8,6 +8,7 @@ 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’:
index cce8c4543ebc40c1ae380e731f237ef03982c454..b3d3d4a3c150450b270b6bf0cc5653d26d79fe82 100644 (file)
@@ -22,6 +22,7 @@ func (i *TInt) TypeName() string {
 func main() {
        var t Type;
        t = nil;
+       _ = t;
 }
 
 /*
index 0f4b2ca178de688e4bc6970298b7c6327a25d7af..c7b17b7c09256aebda95ff0b691084ca4ffcc7fe 100644 (file)
@@ -12,6 +12,7 @@ func main() {
        i = '\\';
        var s string;
        s = "\"";
+       _, _ = i, s;
 }
 /*
 bug.go:5: unknown escape sequence: '
index 061a89da83f267c9f2b426d0bed28c415f470b01..acb4741e9f747ed58984d02b347f78092bdb4462 100644 (file)
@@ -23,6 +23,7 @@ prog := "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"+
 "xxxxxxxx"+
 "xxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
 ;
+_ = prog;
 }
 
 /* Segmentation fault */
index 602b0a130f41f91da6c3419cd97e2193778866ab..c981403edcff1f08aabee5386f21d77abcf11ad3 100644 (file)
@@ -8,4 +8,5 @@ package main
 
 func main() {
        var len int;    // len should not be a keyword - this doesn't compile
+       _ = len;
 }
index a8b1a6cd2b8ec08f5769a162ebca7fed2fed741c..3b6d8642773b6b9a8183d89ea1ad7704a6d37576 100644 (file)
@@ -17,5 +17,6 @@ func main() {
        i = 0;
        type s2 int;
        var k = func (a int) int { return a+1 }(3);
+       _, _ = j, k;
 ro:
 }
index 3847dffb8583b6228c88a85041126a86f803319e..d5d0f1d620e725202c2b5684967ebe47e989cf92 100644 (file)
@@ -16,6 +16,7 @@ func main() {
        l1 := len(s);
        var t T;
        l2 := len(t.s); // BUG: cannot take len() of a string field
+       _, _ = l1, l2;
 }
 
 /*
index 1b78028c420c23ff8ed0aa08ac628f11cc5e1a8f..aedcf70fefe2190db04a8f12dd5788c73632e637 100644 (file)
@@ -9,6 +9,7 @@ package main
 func main() {
        var s string;
        s = "0000000000000000000000000000000000000000000000000000000000"[0:7];
+       _ = s;
 }
 
 /*
index 950ba8e010849cb0a7ad2a16346f7b14559fb93b..d6796cd72be19cdf4427c31208643f519d028633 100644 (file)
@@ -9,10 +9,12 @@ package main
 func main(){
        c := make(chan int);
        ok := false;
-       i := 0;
+       var i int;
 
        i, ok = <-c;  // works
+       _, _ = i, ok;
 
        ca := new([2]chan int);
        i, ok = <-(ca[0]);  // fails: c.go:11: bad shape across assignment - cr=1 cl=2
+       _, _ = i, ok;
 }
index cdd5fc3748b78c3d363dc6b71293ef8184c59c6e..6afdd467d995fa00ffa4e4de83fcec58624d7f6a 100644 (file)
@@ -7,7 +7,7 @@
 package main
 
 func main() {
-       var i, j, k int;
+       var i, k int;
        outer:
        for k=0; k<2; k++ {
                print("outer loop top k ", k, "\n");
index 665a441bdb29ae3aadc52119ba119dfa31e765ad..a5003ffb9762fe1ec3011b7744d56161f8cd471a 100644 (file)
@@ -19,4 +19,5 @@ type dch struct {
 
 func dosplit(in *dch){
        dat := <-in.dat;
+       _ = dat;
 }
index fceeef8cba5f48b89d50b870f34471409021c061..7aed13089dfaabb2f7ef88487443a9e1d2a432cf 100644 (file)
@@ -13,4 +13,5 @@ func main() {
        var x int;
        var ok bool;
        x, ok = t.m[0];  //bug075.go:11: bad shape across assignment - cr=1 cl=2
+       _, _ = x, ok;
 }
index ba6e3b77da8b81fad7823013b4a7927baba8ce69..08028ab10fa902acf1d103894514d74bff4734b4 100644 (file)
@@ -9,4 +9,5 @@ package main
 func main() {
        var exit int;
 exit:
+       _ = exit;
 }
index 2897593dcd1a69b6ab33f5a43726682807565f9a..7556f8dc562b6aa22ca7f68a6efa0b26e9e53e11 100644 (file)
@@ -20,4 +20,5 @@ func main() {
        c := make(chan string);
        a := new(Service);
        go a.Serve(1234);
+       _ = c;
 }
index 6b5e565163f1a0fd1e173dc8776a1ea4847bce67..4af8d976f876f18942645cc72194fc4b1087f0e0 100644 (file)
@@ -10,6 +10,7 @@ const s string = "foo";
 
 func main() {
        i := len(s);  // should be legal to take len() of a constant
+       _ = i;
 }
 
 /*
index 9cb60324d0862491a571e44948277e949ccad266..cadf0e698a565bf141a364e9da2edb1399601e62 100644 (file)
@@ -10,6 +10,7 @@ func main() {
        a0 := P.V0();  // works
        a1 := P.V1();  // works
        a2, b2 := P.V2();  // doesn't work
+       _, _, _, _ = a0, a1, a2, b2;
 }
 
 /*
index 8f18c3852361d89b01123e64ad1271982a935bbe..8f05c478f5c973813f8a21cb1cab48443990930e 100644 (file)
@@ -9,6 +9,7 @@ package main
 func main() {
        var a [1000] int64;  // this alone works
        var b [10000] int64;  // this causes a runtime crash
+       _, _ = a, b;
 }
 
 /*
index 5c5154e86fed5cbfe329ec9a08aa5d292cf03f4b..2953eb28d370be8084ce401cea88ee3c1c24defe 100644 (file)
@@ -13,6 +13,7 @@ func f0() {
 
 func f1() {
        x := 0;
+       _ = x;
 }
 
 
@@ -27,5 +28,5 @@ bug094.go:11: left side of := must be a name
 bad top
 .   LITERAL-I0 l(343)
 bug094.go:11: fatal error: walktype: top=3 LITERAL
-uetli:~/Source/go1/test/bugs gri$ 
+uetli:~/Source/go1/test/bugs gri$
 */
index 81d6c4aada6017e93da8530541278cf1c504480f..9be687a7bb4004aa22dde076b224d2d2a5bb240b 100644 (file)
@@ -11,6 +11,7 @@ type A []int;
 func main() {
        a := &A{0};
        b := &A{0, 1};
+       _, _ = a, b;
 }
 
 /*
index 8e790a709a1f9acfc9253b964fa04abec1567356..1dad4d502aa17e0dd172c0f009db1d863a38c15e 100644 (file)
@@ -12,6 +12,7 @@ type M map[int] int;
 func main() {
        var a *A = &A{0};
        var m *M = &M{0 : 0};  // should be legal to use & here for consistency with other composite constructors (prev. line)
+       _, _ = a, m;
 }
 
 /*
index 1097b1b69c94c0e069343a5ff3975e432d46f6eb..f9f6dd0313ea83bb9184c67a2ab81ce295044280 100644 (file)
@@ -7,5 +7,6 @@
 package foo
 import "fmt"
 func f() {
-       fmt := 1
+       fmt := 1;
+       _ = fmt;
 }
index 252aa87e663a1a33722c80e699fe03003c9dc338..470135ed43b39914660405adaeff1ec485daa47f 100644 (file)
@@ -15,4 +15,5 @@ func main() {
        t := new(T);
        var i interface {};
        f, ok := i.(Foo);
+       _, _, _ = t, f, ok;
 }
index cb86310518d5d5c520a051aa86a7ab65f4cc889e..af960750661fd87660bb266affd42414fef2454f 100644 (file)
@@ -29,7 +29,8 @@ func main() {
        {
                var x int;
                var ok bool;
-               x, ok = f()["key"]
+               x, ok = f()["key"];
+               _, _ = x, ok;
        }
 }
 
index 916566ef0bec7c0900e84f98cc78466e78180b05..bab9a44029d7938de754ce7f53a79e68e2984ac9 100644 (file)
@@ -10,6 +10,7 @@ const c = 1;
 
 func main() {
        c := 0;
+       _ = c;
 }
 
 /*
index 0b41ab59c729a9840db692d1449e25cf2ba7d716..c59bcebd6ef383bb2ce026b0b3275c438c89157a 100644 (file)
@@ -9,7 +9,8 @@ package main
 type t int
 
 func main() {
-       t := 0
+       t := 0;
+       _ = t;
 }
 
 /*
index 66f7212b5740ae1c74a8172ddb1bf1f7beb9f8d8..4371cc5ce9e5def2c53603e5c110a177a458f7e0 100644 (file)
@@ -17,6 +17,7 @@ func f0() string {
 func f1() string {
        const f = 3.141592;
        x := float64(float32(f));  // appears to change the precision of f
+       _ = x;
        return fmt.Sprintf("%v", float64(f));
 }
 
index 690b01265a4a376623196d72ea2c84cbffc7cdfc..67548733ce60b9086bf64cafebfd71ced28e6fe4 100644 (file)
@@ -17,6 +17,7 @@ L:
 
 L1:
        x := 1;
+       _ = x;
        for {
                break L1;       // ERROR "L1"
                continue L1;    // ERROR "L1"
index 12389e797b00beff0644202a575723e9f746f624..66aa5f024b46fce57622ec4a26516fdb26fd92dc 100644 (file)
@@ -12,7 +12,6 @@ func main() {
        // This bug doesn't arise with [...]int, or []interface{} or [3]interface{}.
        a := [...]interface{} { 1, 2, 3 };
        n := 1;
-       bug := false;
        for _, v := range a {
                if v.(int) != n {
                        println("BUG:", n, v.(int));
index 7e5cc7a3fd2ba1b536638162abbf1a20c6da76a3..2fc91b5208b24b283e16fc0ee6030b28fab5aa0d 100644 (file)
@@ -6,11 +6,11 @@
 
 package main
 func f() {
-               v := [...]string{"a", "b"};
+       v := [...]string{"a", "b"};
+       _ = v;
 }
 func main() {
        f();
 }
 
 
\ No newline at end of file
index df9d05e1871ab508eec526246732289afa3731cd..0b1dd637412a381f770e24fb532660e4a9264132 100644 (file)
@@ -10,6 +10,7 @@ import "malloc"
 
 func mk2() {
        b := new([10000]byte);
+       _ = b;
 //     println(b, "stored at", &b);
 }
 
index d746e9c623599ee72538edf7419cdc1bc1f073ad..eecc036fc7c883ad521ed72857268a36b6f57d4d 100644 (file)
@@ -9,5 +9,6 @@ package main
 func main() {
        for i := 0; i < 1000000; i++ {
                x := new([100]byte);
+               _ = x;
        }
 }
index 49007810c6ccc639750bbe4cc51458373eb2ac1f..62943a713a513343fa98c57bcc0c47549cdd4312 100755 (executable)
@@ -171,6 +171,7 @@ func main() {
        var x1 *Number = MakeNumber(1001);
        var x2 *Number = MakeNumber(2002);
        var x3 *Number = MakeNumber(3003);
+       _, _, _ = x1, x2, x3;
 
        // this doesn't work I think...
        //hmap.Lookup(x1, true);
index a2c840eb1a9a9d36cda9a2a411101bb31edf86a3..c7f14c42a6c8e8e7c6c5ec926179229efa04dae9 100644 (file)
@@ -21,56 +21,57 @@ func main() {
 
        count = 0;
        if true {
-               count = count + 1;      
+               count = count + 1;
        }
        assertequal(count, 1, "if true");
 
        count = 0;
        if false {
-               count = count + 1;      
+               count = count + 1;
        }
        assertequal(count, 0, "if false");
 
        count = 0;
        if one := 1; true {
-               count = count + one;    
+               count = count + one;
        }
        assertequal(count, 1, "if true one");
 
        count = 0;
        if one := 1; false {
-               count = count + 1;      
+               count = count + 1;
+               _ = one;
        }
        assertequal(count, 0, "if false one");
 
        count = 0;
        if {
-               count = count + 1;      
+               count = count + 1;
        }
        assertequal(count, 1, "if empty");
 
        count = 0;
        if one := 1; true {
-               count = count + one;    
+               count = count + one;
        }
        assertequal(count, 1, "if empty one");
 
        count = 0;
        if i5 < i7 {
-               count = count + 1;      
+               count = count + 1;
        }
        assertequal(count, 1, "if cond");
 
        count = 0;
        if true {
-               count = count + 1;      
+               count = count + 1;
        } else
                count = count - 1;
        assertequal(count, 1, "if else true");
 
        count = 0;
        if false {
-               count = count + 1;      
+               count = count + 1;
        } else
                count = count - 1;
        assertequal(count, -1, "if else false");
@@ -78,7 +79,9 @@ func main() {
        count = 0;
        if t:=1; false {
                count = count + 1;
-               t := 7; 
+               _ = t;
+               t := 7;
+               _ = t;
        } else
                count = count - t;
        assertequal(count, -1, "if else false var");
@@ -87,8 +90,10 @@ func main() {
        t := 1;
        if false {
                count = count + 1;
-               t := 7; 
+               t := 7;
+               _ = t;
        } else
                count = count - t;
+       _ = t;
        assertequal(count, -1, "if else false var outside");
 }
index f15f5ef0fb3f054173fdf08b38d502ef036428d5..bc219c72f5268f7f599c0a98a9c383efbb4b2d07 100644 (file)
@@ -102,8 +102,7 @@ func main() {
        hello(t.String());
 
        // I2T2 false
-       var u1 U;
-       u1, ok = s.(U);
+       _, ok = s.(U);
        false(ok);
 
        // I2I2 true
index 0e0c4d3ca586f491d1a73174ed8d743bb9695d18..07bd865c897922b0ad6850dc6388c23d4fcb337d 100644 (file)
@@ -18,6 +18,7 @@ func main() {
        var e interface {};
        e = s;
        i = e.(I);
+       _ = i;
 }
 
 // hide S down here to avoid static warning
index d94ec7cadad6d222d00e82d4091427dc0dd46645..be24952ffb2689dbfbcaf3dcd3518f89efe1699c 100644 (file)
@@ -30,7 +30,6 @@ func AddInst(Inst) *Inst {
 }
 
 func main() {
-       re := new(Regexp);
        print("call addinst\n");
        var x Inst = AddInst(new(Start));       // ERROR "illegal|incompatible|is not"
        print("return from  addinst\n");
index 7f257a3baa05f68bedf85972cd01dc66bd1f44ec..8ce96424e3b554d6d06e5307fb4919b8d6b39e27 100644 (file)
@@ -27,17 +27,23 @@ func main() {
 
        v = t;
        p = t;  // ERROR "is not|requires a pointer"
+       _, _= v, p;
        v = &t;
        p = &t;
+       _, _= v, p;
 
        v = s;
        p = s;  // ERROR "is not|requires a pointer"
+       _, _= v, p;
        v = &s;
        p = &s;
+       _, _= v, p;
 
        v = sp;
        p = sp; // no error!
+       _, _= v, p;
        v = &sp;
        p = &sp;
+       _, _= v, p;
 }
 
index 0e18b3b8a0f07895f0340aba0ba4d5a5048cf7a7..518ba29807dbcf415d1e92821e7f83f4564a470b 100644 (file)
@@ -149,7 +149,6 @@ func WhiteSpace(c int) bool
 func NextToken()
 {
        var i, c int;
-       var backslash bool;
 
        tokenbuf[0] = nilchar;  // clear previous token
        c = Get();
@@ -222,8 +221,7 @@ func ParseList() *Slist
 
 func atom(i int) *Slist        // BUG: uses tokenbuf; should take argument
 {
-       var h, length int;
-       var slist, tail *Slist;
+       var slist *Slist;
 
        slist = new(Slist);
        if token == '0' {
index 41d164cd5fcb9160aea87ed4d896dde4ff19b555..b6fe4e4330bac9aaefb5da4399f9df95dbc9ec08 100644 (file)
@@ -21,56 +21,57 @@ func main() {
 
        count = 0;
        if true {
-               count = count + 1;      
+               count = count + 1;
        }
        assertequal(count, 1, "if true");
 
        count = 0;
        if false {
-               count = count + 1;      
+               count = count + 1;
        }
        assertequal(count, 0, "if false");
 
        count = 0;
        if one := 1; true {
-               count = count + one;    
+               count = count + one;
        }
        assertequal(count, 1, "if true one");
 
        count = 0;
        if one := 1; false {
-               count = count + 1;      
+               _ = one;
+               count = count + 1;
        }
        assertequal(count, 0, "if false one");
 
        count = 0;
        if {
-               count = count + 1;      
+               count = count + 1;
        }
        assertequal(count, 1, "if empty");
 
        count = 0;
        if one := 1; {
-               count = count + one;    
+               count = count + one;
        }
        assertequal(count, 1, "if empty one");
 
        count = 0;
        if i5 < i7 {
-               count = count + 1;      
+               count = count + 1;
        }
        assertequal(count, 1, "if cond");
 
        count = 0;
        if true {
-               count = count + 1;      
+               count = count + 1;
        } else
                count = count - 1;
        assertequal(count, 1, "if else true");
 
        count = 0;
        if false {
-               count = count + 1;      
+               count = count + 1;
        } else
                count = count - 1;
        assertequal(count, -1, "if else false");
@@ -78,7 +79,8 @@ func main() {
        count = 0;
        if t:=1; false {
                count = count + 1;
-               t := 7; 
+               t := 7;
+               _ = t;
        } else
                count = count - t;
        assertequal(count, -1, "if else false var");
@@ -87,7 +89,8 @@ func main() {
        t := 1;
        if false {
                count = count + 1;
-               t := 7; 
+               t := 7;
+               _ = t;
        } else
                count = count - t;
        assertequal(count, -1, "if else false var outside");
index 396ea7b4c9e5698b54f5c8b82806676262e6b057..70946bf70ef1dec82ed461ef4f2cf7b31332d8bd 100644 (file)
@@ -19,6 +19,7 @@ main()
                var x int;
                x = 25;
                y = 25;
+               _ = x;
        }
        x = x+y;
        if(x != 40) { panic(x); }
index 00b7b734266da9b6182dc40713b5306fc851ce6b..bd231eae22b00c749a75f83f914c0490930154ba 100644 (file)
@@ -108,6 +108,7 @@ func main() {
        var u31 uint64 = 1;
        var u32 uint64 = 18446744073709551615;
        var u33 uint64 = +18446744073709551615;
+       _, _, _, _ = u30, u31, u32, u33;
 
        // float
        var f00 float = 3.14159;
@@ -192,6 +193,7 @@ func main() {
        assert(s1[4] == 0xc3, "s1-4");
        assert(s1[5] == 0xb4, "s1-5");
        var s2 string = "\a\b\f\n\r\t\v";
+       _, _ = s0, s2;
 
        var s00 string = "\000";
        var s01 string = "\007";
index 6dba3d178160c259b49781b24703ee6b7b595637..43408fef94a81e8653f9b12e40ce449db5722769 100644 (file)
@@ -33,7 +33,6 @@ func main() {
        var ps *S1;
        var i I;
        var pi *I1;
-       var t T;
        var pt *T1;
 
        if s.val() != 1 { panicln("s.val:", s.val()) }
index 1aef54ba9bd891f8bcdfbf2a83d76ea8d9ab3bef..d35309615e8a4f223fba659dc6ebe15075445be1 100644 (file)
@@ -32,4 +32,6 @@ func main() {
        i = nil;
        ta = make([]IN, 1);
        ta[0] = nil;
+
+       _, _, _, _, _, _, _, _ = i, f, s, m, c, t, in, ta;
 }
index 5d5b3a3b8c96449d75591a52f4d9c790e1d56bc4..9215b95fa4ca95913b6a8146ac9e9935bfc4d64a 100644 (file)
@@ -15,7 +15,6 @@ import (
 func main() {
        s := "\000\123\x00\xca\xFE\u0123\ubabe\U0000babe\U0010FFFFx";
        expect := []int{ 0, 0123, 0, 0xFFFD, 0xFFFD, 0x123, 0xbabe, 0xbabe, 0x10FFFF, 'x' };
-       var rune, size int;
        offset := 0;
        var i, c int;
        ok := true;
index f68542053ff2a8529c97a4b2f89a90658779466a..835c90081fcceb18bc62afc95df1e2cf77c814dd 100644 (file)
@@ -73,37 +73,37 @@ func main() {
        case 6:
        case 7:
        case 8:
-       case 9: 
+       case 9:
        default: assert(i5 == 5, "good");
        }
 
        switch i5 {
-       case 0: dummy := 0; fallthrough;
-       case 1: dummy := 0; fallthrough;
-       case 2: dummy := 0; fallthrough;
-       case 3: dummy := 0; fallthrough;
-       case 4: dummy := 0; assert(false, "4");
-       case 5: dummy := 0; fallthrough;
-       case 6: dummy := 0; fallthrough;
-       case 7: dummy := 0; fallthrough;
-       case 8: dummy := 0; fallthrough;
-       case 9: dummy := 0; fallthrough;
-       default: dummy := 0; assert(i5 == 5, "good");
+       case 0: dummy := 0; _ = dummy; fallthrough;
+       case 1: dummy := 0; _ = dummy; fallthrough;
+       case 2: dummy := 0; _ = dummy; fallthrough;
+       case 3: dummy := 0; _ = dummy; fallthrough;
+       case 4: dummy := 0; _ = dummy; assert(false, "4");
+       case 5: dummy := 0; _ = dummy; fallthrough;
+       case 6: dummy := 0; _ = dummy; fallthrough;
+       case 7: dummy := 0; _ = dummy; fallthrough;
+       case 8: dummy := 0; _ = dummy; fallthrough;
+       case 9: dummy := 0; _ = dummy; fallthrough;
+       default: dummy := 0; _ = dummy; assert(i5 == 5, "good");
        }
 
        fired := false;
        switch i5 {
-       case 0: dummy := 0; fallthrough;  // tests scoping of cases
-       case 1: dummy := 0; fallthrough;
-       case 2: dummy := 0; fallthrough;
-       case 3: dummy := 0; fallthrough;
-       case 4: dummy := 0; assert(false, "4");
-       case 5: dummy := 0; fallthrough;
-       case 6: dummy := 0; fallthrough;
-       case 7: dummy := 0; fallthrough;
-       case 8: dummy := 0; fallthrough;
-       case 9: dummy := 0; fallthrough;
-       default: dummy := 0; fired = !fired; assert(i5 == 5, "good");
+       case 0: dummy := 0; _ = dummy; fallthrough;  // tests scoping of cases
+       case 1: dummy := 0; _ = dummy; fallthrough;
+       case 2: dummy := 0; _ = dummy; fallthrough;
+       case 3: dummy := 0; _ = dummy; fallthrough;
+       case 4: dummy := 0; _ = dummy; assert(false, "4");
+       case 5: dummy := 0; _ = dummy; fallthrough;
+       case 6: dummy := 0; _ = dummy; fallthrough;
+       case 7: dummy := 0; _ = dummy; fallthrough;
+       case 8: dummy := 0; _ = dummy; fallthrough;
+       case 9: dummy := 0; _ = dummy; fallthrough;
+       default: dummy := 0; _ = dummy; fired = !fired; assert(i5 == 5, "good");
        }
        assert(fired, "fired");
 
index 9e2021485d7c21da1563e1bf4c2957187f1e725c..f42b12b3c5166d1e23b803ebca752b1dcde93f2e 100644 (file)
@@ -58,12 +58,14 @@ func control_structs() {
        var p *Point = new(Point).Initialize(2, 3);
        i := p.Distance();
        var f float = 0.3;
+       _ = f;
        for {}
        for {};
        for j := 0; j < i; j++ {
                if i == 0 {
                } else i = 0;
                var x float;
+               _ = x;
        }
        foo:    // a label
        var j int;