package p
-type _ comparable // ERROR undeclared
+type _ comparable // ERROR predeclared comparable
package p
-type T[P /* ERROR type parameter requires go1\.18 or later */ any /* ERROR undeclared name: any \(requires version go1\.18 or later\) */ ] struct{}
+type T[P /* ERROR type parameter requires go1\.18 or later */ any /* ERROR predeclared any requires go1\.18 or later */] struct{}
// for init (and main, but we're not in package main) we should only get one error
-func init[P /* ERROR func init must have no type parameters */ any /* ERROR undeclared name: any \(requires version go1\.18 or later\) */ ]() {}
-func main[P /* ERROR type parameter requires go1\.18 or later */ any /* ERROR undeclared name: any \(requires version go1\.18 or later\) */ ]() {}
+func init[P /* ERROR func init must have no type parameters */ any /* ERROR predeclared any requires go1\.18 or later */]() {
+}
+func main[P /* ERROR type parameter requires go1\.18 or later */ any /* ERROR predeclared any requires go1\.18 or later */]() {
+}
-func f[P /* ERROR type parameter requires go1\.18 or later */ any /* ERROR undeclared name: any \(requires version go1\.18 or later\) */ ](x P) {
+func f[P /* ERROR type parameter requires go1\.18 or later */ any /* ERROR predeclared any requires go1\.18 or later */](x P) {
var _ T[ /* ERROR type instantiation requires go1\.18 or later */ int]
var _ (T[ /* ERROR type instantiation requires go1\.18 or later */ int])
_ = T[ /* ERROR type instantiation requires go1\.18 or later */ int]{}
}
type C1 interface {
- comparable // ERROR undeclared name: comparable \(requires version go1\.18 or later\)
+ comparable // ERROR predeclared comparable requires go1\.18 or later
}
type C2 interface {
- comparable // ERROR undeclared name: comparable \(requires version go1\.18 or later\)
+ comparable // ERROR predeclared comparable requires go1\.18 or later
int // ERROR embedding non-interface type int requires go1\.18 or later
~ /* ERROR embedding interface element ~int requires go1\.18 or later */ int
int /* ERROR embedding interface element int\|~string requires go1\.18 or later */ | ~string
}
type (
- _ comparable // ERROR undeclared name: comparable \(requires version go1\.18 or later\)
+ _ comparable // ERROR predeclared comparable requires go1\.18 or later
// errors for these were reported with their declaration
_ C1
_ C2
- _ = comparable // ERROR undeclared name: comparable \(requires version go1\.18 or later\)
+ _ = comparable // ERROR predeclared comparable requires go1\.18 or later
// errors for these were reported with their declaration
_ = C1
_ = C2
return
case universeAny, universeComparable:
if !check.allowVersion(check.pkg, 1, 18) {
- check.errorf(e, "undeclared name: %s (requires version go1.18 or later)", e.Value)
+ check.versionErrorf(e, "go1.18", "predeclared %s", e.Value)
return // avoid follow-on errors
}
}
check.report(err)
}
+func (check *Checker) versionErrorf(at positioner, code errorCode, goVersion string, format string, args ...interface{}) {
+ msg := check.sprintf(format, args...)
+ var err *error_
+ if compilerErrorMessages {
+ err = newErrorf(at, code, "%s requires %s or later (-lang was set to %s; check go.mod)", msg, goVersion, check.conf.GoVersion)
+ } else {
+ err = newErrorf(at, code, "%s requires %s or later", msg, goVersion)
+ }
+ check.report(err)
+}
+
func (check *Checker) invalidAST(at positioner, format string, args ...any) {
check.errorf(at, 0, "invalid AST: "+format, args...)
}
package p
-type _ comparable // ERROR undeclared
+type _ comparable // ERROR predeclared comparable
package p
-type T[P /* ERROR type parameters require go1\.18 or later */ any /* ERROR undeclared name: any \(requires version go1\.18 or later\) */ ] struct{}
+type T[P /* ERROR type parameters require go1\.18 or later */ any /* ERROR predeclared any requires go1\.18 or later */ ] struct{}
// for init (and main, but we're not in package main) we should only get one error
-func init[P /* ERROR func init must have no type parameters */ any /* ERROR undeclared name: any \(requires version go1\.18 or later\) */ ]() {}
-func main[P /* ERROR type parameters require go1\.18 or later */ any /* ERROR undeclared name: any \(requires version go1\.18 or later\) */ ]() {}
+func init[P /* ERROR func init must have no type parameters */ any /* ERROR predeclared any requires go1\.18 or later */ ]() {}
+func main[P /* ERROR type parameters require go1\.18 or later */ any /* ERROR predeclared any requires go1\.18 or later */ ]() {}
-func f[P /* ERROR type parameters require go1\.18 or later */ any /* ERROR undeclared name: any \(requires version go1\.18 or later\) */ ](x P) {
+func f[P /* ERROR type parameters require go1\.18 or later */ any /* ERROR predeclared any requires go1\.18 or later */ ](x P) {
var _ T[ /* ERROR type instantiation requires go1\.18 or later */ int]
var _ (T[ /* ERROR type instantiation requires go1\.18 or later */ int])
_ = T[ /* ERROR type instantiation requires go1\.18 or later */ int]{}
}
type C1 interface {
- comparable // ERROR undeclared name: comparable \(requires version go1\.18 or later\)
+ comparable // ERROR predeclared comparable requires go1\.18 or later
}
type C2 interface {
- comparable // ERROR undeclared name: comparable \(requires version go1\.18 or later\)
+ comparable // ERROR predeclared comparable requires go1\.18 or later
int // ERROR embedding non-interface type int requires go1\.18 or later
~ /* ERROR embedding interface element ~int requires go1\.18 or later */ int
int /* ERROR embedding interface element int\|~string requires go1\.18 or later */ | ~string
}
type (
- _ comparable // ERROR undeclared name: comparable \(requires version go1\.18 or later\)
+ _ comparable // ERROR predeclared comparable requires go1\.18 or later
// errors for these were reported with their declaration
_ C1
_ C2
- _ = comparable // ERROR undeclared name: comparable \(requires version go1\.18 or later\)
+ _ = comparable // ERROR predeclared comparable requires go1\.18 or later
// errors for these were reported with their declaration
_ = C1
_ = C2
return
case universeAny, universeComparable:
if !check.allowVersion(check.pkg, 1, 18) {
- check.errorf(e, _UndeclaredName, "undeclared name: %s (requires version go1.18 or later)", e.Name)
+ check.versionErrorf(e, _UndeclaredName, "go1.18", "predeclared %s", e.Name)
return // avoid follow-on errors
}
}