Russ Cox | 14be733 | 2009-08-24 13:41:47 -0700 | [diff] [blame] | 1 | // errchk $G $D/$F.go |
| 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 | package main |
| 8 | |
| 9 | type T int |
| 10 | type U int |
| 11 | |
| 12 | var x int |
| 13 | |
Ian Lance Taylor | 1a05177 | 2009-08-31 21:39:08 -0700 | [diff] [blame] | 14 | var t T = int(0) // ERROR "cannot use|incompatible" |
| 15 | var t1 T = int(x) // ERROR "cannot use|incompatible" |
| 16 | var u U = int(0) // ERROR "cannot use|incompatible" |
| 17 | var u1 U = int(x) // ERROR "cannot use|incompatible" |
Russ Cox | 14be733 | 2009-08-24 13:41:47 -0700 | [diff] [blame] | 18 | |
| 19 | type S string |
| 20 | var s S |
| 21 | |
| 22 | var s1 = s + "hello" |
| 23 | var s2 = "hello" + s |
Ian Lance Taylor | 1a05177 | 2009-08-31 21:39:08 -0700 | [diff] [blame] | 24 | var s3 = s + string("hello") // ERROR "invalid operation|incompatible" |
| 25 | var s4 = string("hello") + s // ERROR "invalid operation|incompatible" |
Russ Cox | 14be733 | 2009-08-24 13:41:47 -0700 | [diff] [blame] | 26 | |
| 27 | var r string |
| 28 | |
| 29 | var r1 = r + "hello" |
| 30 | var r2 = "hello" + r |
| 31 | var r3 = r + string("hello") |
| 32 | var r4 = string("hello") + r |
| 33 | |