var why string
op := assignop(n.Type, t, &why)
if op == 0 {
- yyerror("cannot use %L as type %v in %s%s", n, t, context(), why)
+ if !old.Diag() {
+ yyerror("cannot use %L as type %v in %s%s", n, t, context(), why)
+ }
op = OCONV
}
--- /dev/null
+// errorcheck
+
+// Copyright 2017 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.
+
+// Check that we don't print duplicate errors for string ->
+// array-literal conversion
+
+package main
+
+func main() {
+ _ = []byte{"foo"} // ERROR "cannot convert"
+ _ = []int{"foo"} // ERROR "cannot convert"
+ _ = []rune{"foo"} // ERROR "cannot convert"
+ _ = []string{"foo"} // OK
+}
i2 = I2(i) // ERROR "invalid|missing N method"
e = E(t) // ok
- t = T(e) // ERROR "need explicit|need type assertion|incompatible" "as type [*]T"
+ t = T(e) // ERROR "need explicit|need type assertion|incompatible"
}
type M interface {
var m3 = M(ii) // ERROR "invalid|missing"
var m4 = M(jj) // ERROR "invalid|wrong type for M method"
-
type B1 interface {
_() // ERROR "methods must have a unique non-blank name"
}