blob: 84a4a1aa55cd58cf2169b1c2b83ec517d67f6a26 [file] [log] [blame]
Brent Austinba3052e2015-04-21 16:08:23 -07001// run
2
3// Copyright 2009 The Go Authors. All rights reserved.
4// Use of this source code is governed by a BSD-style
5// license that can be found in the LICENSE file.
6
7// Test var x = x + 1 works.
8
9package main
10
11func main() {
12 var x int = 1
13 if x != 1 {
14 print("found ", x, ", expected 1\n")
15 panic("fail")
16 }
17 {
18 var x int = x + 1
19 if x != 2 {
20 print("found ", x, ", expected 2\n")
21 panic("fail")
22 }
23 }
24 {
25 x := x + 1
26 if x != 2 {
27 print("found ", x, ", expected 2\n")
28 panic("fail")
29 }
30 }
31}