}
if !ok {
- check.errorf(x, "cannot convert %s to %s", x, T)
- x.mode = invalid
+ if x.mode != invalid {
+ check.errorf(x, "cannot convert %s to %s", x, T)
+ x.mode = invalid
+ }
return
}
if p := asPointer(T); p != nil {
if a := asArray(p.Elem()); a != nil {
if check.identical(s.Elem(), a.Elem()) {
- return true
+ if check == nil || check.allowVersion(check.pkg, 1, 17) {
+ return true
+ }
+ // check != nil
+ if check.conf.CompilerErrorMessages {
+ check.error(x, "conversion of slices to array pointers only supported as of -lang=go1.17")
+ } else {
+ check.error(x, "conversion of slices to array pointers requires go1.17 or later")
+ }
+ x.mode = invalid // avoid follow-up error
}
}
}
if alias {
// type alias declaration
- if !check.allowVersion(obj.pkg, 1, 9) {
+ if !check.allowVersion(check.pkg, 1, 9) {
if check.conf.CompilerErrorMessages {
check.error(tdecl, "type aliases only supported as of -lang=go1.9")
} else {
--- /dev/null
+// Copyright 2021 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 Go language version-specific errors.
+
+package go1_16 // go1.16
+
+type Slice []byte
+type Array [8]byte
+
+var s Slice
+var p = (*Array)(s /* ERROR requires go1.17 or later */ )