diff options
author | Ian Lance Taylor <iant@golang.org> | 2008-11-17 12:19:02 -0800 |
---|---|---|
committer | Ian Lance Taylor <iant@golang.org> | 2008-11-17 12:19:02 -0800 |
commit | 4e6aced39941769491bf4923cbd55e2811679451 (patch) | |
tree | a4ca81322eace9f869821b3feab0019da2c1d68c /test/varinit.go | |
parent | f7acd942b2d01c62729d68dec026c140230bb394 (diff) | |
download | go-4e6aced39941769491bf4923cbd55e2811679451.tar.gz |
The scope rules have been clarified to indicate that a
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
Diffstat (limited to 'test/varinit.go')
-rw-r--r-- | test/varinit.go | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/test/varinit.go b/test/varinit.go new file mode 100644 index 000000000..a49410051 --- /dev/null +++ b/test/varinit.go @@ -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"); } + } +} |