1 // Copyright 2013 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file.
7 // Testing precise operand formatting in error messages
8 // (matching messages are regular expressions, hence the \'s).
9 func f(x int, m map[string]int) {
11 _ = f /* ERROR "f\(0, m\) \(no value\) used as value" */ (0, m)
14 _ = println /* ERROR "println \(built-in\) must be called" */
17 _ = complex128 /* ERROR "complex128 \(type\) is not an expression" */
21 const c2 float32 = 0.5
22 0 /* ERROR "0 \(untyped int constant\) is not used" */
23 c1 /* ERROR "c1 \(untyped int constant 991\) is not used" */
24 c2 /* ERROR "c2 \(constant 0.5 of type float32\) is not used" */
25 c1 /* ERROR "c1 \+ c2 \(constant 991.5 of type float32\) is not used" */ + c2
28 x /* ERROR "x \(variable of type int\) is not used" */
31 x /* ERROR "x != x \(untyped bool value\) is not used" */ != x
32 x /* ERROR "x \+ x \(value of type int\) is not used" */ + x
36 m /* ERROR "m\[s\] \(map index expression of type int\) is not used" */ [s]
39 // Valid ERROR comments can have a variety of forms.
41 0 /* ERROR "0 .* is not used" */
42 0 /* ERROR 0 .* is not used */
43 0 // ERROR "0 .* is not used"
44 0 // ERROR 0 .* is not used
47 // Don't report spurious errors as a consequence of earlier errors.
48 // Add more tests as needed.
50 if err := foo /* ERROR undeclared */ (); err != nil /* no error here */ {}
53 // Use unqualified names for package-local objects.
55 var _ int = T /* ERROR value of type T */ {} // use T in error message rather then errors.T