2011-11-09 02:58:53 -07:00
|
|
|
// errchk $G -e $D/$F.go
|
|
|
|
|
|
|
|
// Copyright 2011 The Go Authors. All rights reserved.
|
|
|
|
// Use of this source code is governed by a BSD-style
|
|
|
|
// license that can be found in the LICENSE file.
|
|
|
|
|
|
|
|
package main
|
|
|
|
|
|
|
|
type I interface {
|
2011-11-13 20:58:08 -07:00
|
|
|
M()
|
2011-11-09 02:58:53 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
func bad() {
|
|
|
|
var i I
|
|
|
|
var s string
|
|
|
|
|
|
|
|
switch i {
|
2012-01-27 00:06:47 -07:00
|
|
|
case s: // ERROR "mismatched types string and I|incompatible types"
|
2011-11-09 02:58:53 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
switch s {
|
2012-01-27 00:06:47 -07:00
|
|
|
case i: // ERROR "mismatched types I and string|incompatible types"
|
2011-11-13 20:58:08 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
var m, m1 map[int]int
|
|
|
|
switch m {
|
|
|
|
case nil:
|
2012-01-27 00:06:47 -07:00
|
|
|
case m1: // ERROR "can only compare map m to nil|map can only be compared to nil"
|
2011-11-13 20:58:08 -07:00
|
|
|
default:
|
|
|
|
}
|
|
|
|
|
|
|
|
var a, a1 []int
|
|
|
|
switch a {
|
|
|
|
case nil:
|
2012-01-27 00:06:47 -07:00
|
|
|
case a1: // ERROR "can only compare slice a to nil|slice can only be compared to nil"
|
2011-11-13 20:58:08 -07:00
|
|
|
default:
|
|
|
|
}
|
|
|
|
|
|
|
|
var f, f1 func()
|
|
|
|
switch f {
|
|
|
|
case nil:
|
2012-01-27 00:06:47 -07:00
|
|
|
case f1: // ERROR "can only compare func f to nil|func can only be compared to nil"
|
2011-11-13 20:58:08 -07:00
|
|
|
default:
|
2011-11-09 02:58:53 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func good() {
|
|
|
|
var i interface{}
|
|
|
|
var s string
|
|
|
|
|
|
|
|
switch i {
|
|
|
|
case s:
|
|
|
|
}
|
|
|
|
|
|
|
|
switch s {
|
|
|
|
case i:
|
|
|
|
}
|
|
|
|
}
|