aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/compile/internal/types2/typexpr.go
diff options
context:
space:
mode:
Diffstat (limited to 'src/cmd/compile/internal/types2/typexpr.go')
-rw-r--r--src/cmd/compile/internal/types2/typexpr.go15
1 files changed, 8 insertions, 7 deletions
diff --git a/src/cmd/compile/internal/types2/typexpr.go b/src/cmd/compile/internal/types2/typexpr.go
index 241c6d35fe..f3e415e4c7 100644
--- a/src/cmd/compile/internal/types2/typexpr.go
+++ b/src/cmd/compile/internal/types2/typexpr.go
@@ -38,14 +38,12 @@ func (check *Checker) ident(x *operand, e *syntax.Name, def *Named, wantType boo
}
return
case universeAny, universeComparable:
+ // complain if necessary but keep going
if !check.allowVersion(check.pkg, 1, 18) {
- check.errorf(e, "undeclared name: %s (requires version go1.18 or later)", e.Value)
- return
- }
- // If we allow "any" for general use, this if-statement can be removed (issue #33232).
- if obj == universeAny {
- check.error(e, "cannot use any outside constraint position")
- return
+ check.softErrorf(e, "undeclared name: %s (requires version go1.18 or later)", e.Value)
+ } else if obj == universeAny {
+ // If we allow "any" for general use, this if-statement can be removed (issue #33232).
+ check.softErrorf(e, "cannot use any outside constraint position")
}
}
check.recordUse(e, obj)
@@ -274,6 +272,9 @@ func (check *Checker) typInternal(e0 syntax.Expr, def *Named) (T Type) {
}
case *syntax.IndexExpr:
+ if !check.allowVersion(check.pkg, 1, 18) {
+ check.softErrorf(e.Pos(), "type instantiation requires go1.18 or later")
+ }
return check.instantiatedType(e.X, unpackExpr(e.Index), def)
case *syntax.ParenExpr: