]> Cypherpunks.ru repositories - gostls13.git/commitdiff
The scope rules have been clarified to indicate that a
authorIan Lance Taylor <iant@golang.org>
Mon, 17 Nov 2008 20:19:02 +0000 (12:19 -0800)
committerIan Lance Taylor <iant@golang.org>
Mon, 17 Nov 2008 20:19:02 +0000 (12:19 -0800)
variable may only be named after the complete declaration,
including the initialization statements.

R=gri
DELTA=61  (16 added, 45 deleted, 0 changed)
OCL=19343
CL=19376

test/bugs/bug095.go [deleted file]
test/golden.out
test/varinit.go [new file with mode: 0644]

diff --git a/test/bugs/bug095.go b/test/bugs/bug095.go
deleted file mode 100644 (file)
index 5684f7b..0000000
+++ /dev/null
@@ -1,43 +0,0 @@
-// 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.
-
-// $G $D/$F.go && $L $F.$A && ./$A.out || echo BUG wrong result
-
-package main
-
-func main() {
-   var x int = 1;
-   if x != 1 { panic("found ", x, ", expected 1\n"); }
-   {
-          var x int = x + 1;  // scope of x starts too late
-          if x != 1 { panic("found ", x, ", expected 1\n"); }
-   }
-   {
-          x := x + 1;  // scope of x starts too late
-          if x != 1 { panic("found ", x, ", expected 1\n"); }
-   }
-}
-
-/*
-uetli:~/Source/go1/test/bugs gri$ 6g bug095.go && 6l bug095.6 && 6.out
-found 2, expected 1
-
-panic on line 342 PC=0x139e
-0x139e?zi
-       mainĀ·main(1, 0, 1606416416, ...)
-       mainĀ·main(0x1, 0x7fff5fbff820, 0x0, ...)
-Trace/BPT trap
-*/
-
-/*
-Example: If I write
-
-type Tree struct {
-       left, right *Tree
-}
-
-I expect the correct *Tree to picked up; i.e. the scope of the identifier
-Tree starts immediately after the name is declared. There is no reason why
-this should be different for vars.
-*/
index 3d7795022b14724401ed438198708fb795c50597..80e26af5c7abec790c726f323e37336399db0baf 100644 (file)
@@ -109,12 +109,6 @@ bugs/bug087.go:8: illegal combination of literals LEN 9
 bugs/bug087.go:8: illegal combination of literals LEN 9
 BUG: fails incorrectly
 
-=========== bugs/bug095.go
-found 2, expected 1
-
-panic on line 80 PC=xxx
-BUG wrong result
-
 =========== bugs/bug098.go
 bugs/bug098.go:10: illegal types for operand: AS
        *M
diff --git a/test/varinit.go b/test/varinit.go
new file mode 100644 (file)
index 0000000..a494100
--- /dev/null
@@ -0,0 +1,20 @@
+// $G $D/$F.go && $L $F.$A && ./$A.out || echo BUG wrong result
+
+// 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 = 1;
+   if x != 1 { panic("found ", x, ", expected 1\n"); }
+   {
+          var x int = x + 1;
+          if x != 2 { panic("found ", x, ", expected 2\n"); }
+   }
+   {
+          x := x + 1;
+          if x != 2 { panic("found ", x, ", expected 2\n"); }
+   }
+}