1
0
mirror of https://github.com/golang/go synced 2024-11-18 06:14:46 -07:00

go/types, types2: consistently use _UnsupportedFeature error code

Change-Id: Ie880871bb855e1c1f6e543508bdc7dd415451ba3
Reviewed-on: https://go-review.googlesource.com/c/go/+/429735
Reviewed-by: Robert Griesemer <gri@google.com>
Auto-Submit: Robert Griesemer <gri@google.com>
Run-TryBot: Robert Griesemer <gri@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
This commit is contained in:
Robert Griesemer 2022-09-08 16:33:08 -07:00 committed by Gopher Robot
parent f4a587ba6e
commit c7a0b15659
8 changed files with 18 additions and 18 deletions

View File

@ -279,7 +279,7 @@ const (
// _InvalidIfaceEmbed occurs when a non-interface type is embedded in an
// interface (for go 1.17 or earlier).
_InvalidIfaceEmbed
_ // not used anymore
// _InvalidPtrEmbed occurs when an embedded field is of the pointer form *T,
// and T itself is itself a pointer, an unsafe.Pointer, or an interface.
@ -1419,5 +1419,5 @@ const (
// _InvalidUnsafeStringData occurs if it is used in a package
// compiled for a language version before go1.20.
_InvalidUnsafeStringData
_ // not used anymore
)

View File

@ -978,7 +978,7 @@ func (check *Checker) shift(x, y *operand, e syntax.Expr, op syntax.Operator) {
switch {
case allInteger(y.typ):
if !allUnsigned(y.typ) && !check.allowVersion(check.pkg, 1, 13) {
check.errorf(y, _InvalidShiftCount, invalidOp+"signed shift count %s requires go1.13 or later", y)
check.versionErrorf(y, "go1.13", invalidOp+"signed shift count %s", y)
x.mode = invalid
return
}

View File

@ -604,7 +604,7 @@ func (check *Checker) builtin(x *operand, call *ast.CallExpr, id builtinId) (_ b
case _Add:
// unsafe.Add(ptr unsafe.Pointer, len IntegerType) unsafe.Pointer
if !check.allowVersion(check.pkg, 1, 17) {
check.errorf(call.Fun, _InvalidUnsafeAdd, "unsafe.Add requires go1.17 or later")
check.errorf(call.Fun, _UnsupportedFeature, "unsafe.Add requires go1.17 or later")
return
}
@ -730,7 +730,7 @@ func (check *Checker) builtin(x *operand, call *ast.CallExpr, id builtinId) (_ b
case _Slice:
// unsafe.Slice(ptr *T, len IntegerType) []T
if !check.allowVersion(check.pkg, 1, 17) {
check.errorf(call.Fun, _InvalidUnsafeSlice, "unsafe.Slice requires go1.17 or later")
check.errorf(call.Fun, _UnsupportedFeature, "unsafe.Slice requires go1.17 or later")
return
}
@ -755,7 +755,7 @@ func (check *Checker) builtin(x *operand, call *ast.CallExpr, id builtinId) (_ b
case _SliceData:
// unsafe.SliceData(slice []T) *T
if !check.allowVersion(check.pkg, 1, 20) {
check.errorf(call.Fun, _InvalidUnsafeSliceData, "unsafe.SliceData requires go1.20 or later")
check.errorf(call.Fun, _UnsupportedFeature, "unsafe.SliceData requires go1.20 or later")
return
}
@ -774,7 +774,7 @@ func (check *Checker) builtin(x *operand, call *ast.CallExpr, id builtinId) (_ b
case _String:
// unsafe.String(ptr *byte, len IntegerType) string
if !check.allowVersion(check.pkg, 1, 20) {
check.errorf(call.Fun, _InvalidUnsafeString, "unsafe.String requires go1.20 or later")
check.errorf(call.Fun, _UnsupportedFeature, "unsafe.String requires go1.20 or later")
return
}
@ -798,7 +798,7 @@ func (check *Checker) builtin(x *operand, call *ast.CallExpr, id builtinId) (_ b
case _StringData:
// unsafe.StringData(str string) *byte
if !check.allowVersion(check.pkg, 1, 20) {
check.errorf(call.Fun, _InvalidUnsafeStringData, "unsafe.StringData requires go1.20 or later")
check.errorf(call.Fun, _UnsupportedFeature, "unsafe.StringData requires go1.20 or later")
return
}

View File

@ -569,7 +569,7 @@ func (check *Checker) typeDecl(obj *TypeName, tdecl *ast.TypeSpec, def *Named) {
// alias declaration
if alias {
if !check.allowVersion(check.pkg, 1, 9) {
check.errorf(atPos(tdecl.Assign), _BadDecl, "type aliases requires go1.9 or later")
check.errorf(atPos(tdecl.Assign), _UnsupportedFeature, "type aliases requires go1.9 or later")
}
check.brokenAlias(obj)

View File

@ -279,7 +279,7 @@ const (
// _InvalidIfaceEmbed occurs when a non-interface type is embedded in an
// interface (for go 1.17 or earlier).
_InvalidIfaceEmbed
_ // not used anymore
// _InvalidPtrEmbed occurs when an embedded field is of the pointer form *T,
// and T itself is itself a pointer, an unsafe.Pointer, or an interface.
@ -1419,5 +1419,5 @@ const (
// _InvalidUnsafeStringData occurs if it is used in a package
// compiled for a language version before go1.20.
_InvalidUnsafeStringData
_ // not used anymore
)

View File

@ -955,7 +955,7 @@ func (check *Checker) shift(x, y *operand, e ast.Expr, op token.Token) {
switch {
case allInteger(y.typ):
if !allUnsigned(y.typ) && !check.allowVersion(check.pkg, 1, 13) {
check.invalidOp(y, _InvalidShiftCount, "signed shift count %s requires go1.13 or later", y)
check.invalidOp(y, _UnsupportedFeature, "signed shift count %s requires go1.13 or later", y)
x.mode = invalid
return
}

View File

@ -286,7 +286,7 @@ func computeInterfaceTypeSet(check *Checker, pos token.Pos, ityp *Interface) *_T
terms = tset.terms
case *Union:
if check != nil && !check.allowVersion(check.pkg, 1, 18) {
check.errorf(atPos(pos), _InvalidIfaceEmbed, "embedding interface element %s requires go1.18 or later", u)
check.errorf(atPos(pos), _UnsupportedFeature, "embedding interface element %s requires go1.18 or later", u)
continue
}
tset := computeUnionTypeSet(check, unionSets, pos, u)
@ -301,7 +301,7 @@ func computeInterfaceTypeSet(check *Checker, pos token.Pos, ityp *Interface) *_T
continue
}
if check != nil && !check.allowVersion(check.pkg, 1, 18) {
check.errorf(atPos(pos), _InvalidIfaceEmbed, "embedding non-interface type %s requires go1.18 or later", typ)
check.errorf(atPos(pos), _UnsupportedFeature, "embedding non-interface type %s requires go1.18 or later", typ)
continue
}
terms = termlist{{false, typ}}

View File

@ -22,7 +22,7 @@ func (check *Checker) langCompat(lit *ast.BasicLit) {
}
// len(s) > 2
if strings.Contains(s, "_") {
check.errorf(lit, _InvalidLit, "underscores in numeric literals requires go1.13 or later")
check.errorf(lit, _UnsupportedFeature, "underscores in numeric literals requires go1.13 or later")
return
}
if s[0] != '0' {
@ -30,15 +30,15 @@ func (check *Checker) langCompat(lit *ast.BasicLit) {
}
radix := s[1]
if radix == 'b' || radix == 'B' {
check.errorf(lit, _InvalidLit, "binary literals requires go1.13 or later")
check.errorf(lit, _UnsupportedFeature, "binary literals requires go1.13 or later")
return
}
if radix == 'o' || radix == 'O' {
check.errorf(lit, _InvalidLit, "0o/0O-style octal literals requires go1.13 or later")
check.errorf(lit, _UnsupportedFeature, "0o/0O-style octal literals requires go1.13 or later")
return
}
if lit.Kind != token.INT && (radix == 'x' || radix == 'X') {
check.errorf(lit, _InvalidLit, "hexadecimal floating-point literals requires go1.13 or later")
check.errorf(lit, _UnsupportedFeature, "hexadecimal floating-point literals requires go1.13 or later")
}
}