Russ Cox | 0b477ef | 2012-02-16 23:48:57 -0500 | [diff] [blame] | 1 | // errorcheck |
Russ Cox | 1163b1d | 2008-10-16 15:59:31 -0700 | [diff] [blame] | 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 | |
Rob Pike | fc0dc04 | 2012-02-19 13:19:43 +1100 | [diff] [blame] | 7 | // Verify that illegal uses of composite literals are detected. |
| 8 | // Does not compile. |
| 9 | |
Russ Cox | 1163b1d | 2008-10-16 15:59:31 -0700 | [diff] [blame] | 10 | package main |
| 11 | |
Russ Cox | 9dc22b6 | 2009-08-03 11:58:52 -0700 | [diff] [blame] | 12 | var a = []int { "a" }; // ERROR "conver|incompatible|cannot" |
Russ Cox | be2edb5 | 2009-03-03 08:39:12 -0800 | [diff] [blame] | 13 | var b = int { 1 }; // ERROR "compos" |
Russ Cox | 1163b1d | 2008-10-16 15:59:31 -0700 | [diff] [blame] | 14 | |
| 15 | |
Russ Cox | f48cbfd | 2009-01-16 16:12:14 -0800 | [diff] [blame] | 16 | func f() int |
| 17 | |
Russ Cox | 1163b1d | 2008-10-16 15:59:31 -0700 | [diff] [blame] | 18 | func main() { |
Russ Cox | 9dc22b6 | 2009-08-03 11:58:52 -0700 | [diff] [blame] | 19 | if f < 1 { } // ERROR "conver|incompatible|invalid" |
Russ Cox | 1163b1d | 2008-10-16 15:59:31 -0700 | [diff] [blame] | 20 | } |