| 1 |
// errorcheck |
| 2 |
|
| 3 |
// Copyright 2021 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 p |
| 8 |
|
| 9 |
var s string |
| 10 |
var b bool |
| 11 |
var i int |
| 12 |
var iface interface{} |
| 13 |
|
| 14 |
var ( |
| 15 |
_ = "" + b // ERROR "invalid operation.*mismatched types.*untyped string and bool" |
| 16 |
_ = "" + i // ERROR "invalid operation.*mismatched types.*untyped string and int" |
| 17 |
_ = "" + nil // ERROR "invalid operation.*mismatched types.*untyped string and nil|(untyped nil)" |
| 18 |
) |
| 19 |
|
| 20 |
var ( |
| 21 |
_ = s + false // ERROR "invalid operation.*mismatched types.*string and untyped bool" |
| 22 |
_ = s + 1 // ERROR "invalid operation.*mismatched types.*string and untyped int" |
| 23 |
_ = s + nil // ERROR "invalid operation.*mismatched types.*string and nil|(untyped nil)" |
| 24 |
) |
| 25 |
|
| 26 |
var ( |
| 27 |
_ = "" + false // ERROR "invalid operation.*mismatched types.*untyped string and untyped bool" |
| 28 |
_ = "" + 1 // ERROR "invalid operation.*mismatched types.*untyped string and untyped int" |
| 29 |
) |
| 30 |
|
| 31 |
var ( |
| 32 |
_ = b + 1 // ERROR "invalid operation.*mismatched types.*bool and untyped int" |
| 33 |
_ = i + false // ERROR "invalid operation.*mismatched types.*int and untyped bool" |
| 34 |
_ = iface + 1 // ERROR "invalid operation.*mismatched types.*interface *{} and untyped int" |
| 35 |
_ = iface + 1.0 // ERROR "invalid operation.*mismatched types.*interface *{} and untyped float" |
| 36 |
_ = iface + false // ERROR "invalid operation.*mismatched types.*interface *{} and bool" |
| 37 |
) |