mirror of
https://github.com/golang/go.git
synced 2025-05-05 15:43:04 +00:00
go/types, types2: consistently use singular when reporting version errors
Change-Id: I39af932b789cd18dc4bfc84f9667b1c32c9825f4 Reviewed-on: https://go-review.googlesource.com/c/go/+/567476 Reviewed-by: Robert Findley <rfindley@google.com> Reviewed-by: Robert Griesemer <gri@google.com> Auto-Submit: Robert Griesemer <gri@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
This commit is contained in:
parent
1a6498e1cb
commit
5e00352b9b
@ -203,7 +203,7 @@ func (x *operand) convertibleTo(check *Checker, T Type, cause *string) bool {
|
||||
// check != nil
|
||||
if cause != nil {
|
||||
// TODO(gri) consider restructuring versionErrorf so we can use it here and below
|
||||
*cause = "conversion of slices to arrays requires go1.20 or later"
|
||||
*cause = "conversion of slice to array requires go1.20 or later"
|
||||
}
|
||||
return false
|
||||
}
|
||||
@ -215,7 +215,7 @@ func (x *operand) convertibleTo(check *Checker, T Type, cause *string) bool {
|
||||
}
|
||||
// check != nil
|
||||
if cause != nil {
|
||||
*cause = "conversion of slices to array pointers requires go1.17 or later"
|
||||
*cause = "conversion of slice to array pointer requires go1.17 or later"
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
@ -59,7 +59,7 @@ func (check *Checker) langCompat(lit *syntax.BasicLit) {
|
||||
}
|
||||
// len(s) > 2
|
||||
if strings.Contains(s, "_") {
|
||||
check.versionErrorf(lit, go1_13, "underscores in numeric literals")
|
||||
check.versionErrorf(lit, go1_13, "underscore in numeric literal")
|
||||
return
|
||||
}
|
||||
if s[0] != '0' {
|
||||
@ -67,15 +67,15 @@ func (check *Checker) langCompat(lit *syntax.BasicLit) {
|
||||
}
|
||||
radix := s[1]
|
||||
if radix == 'b' || radix == 'B' {
|
||||
check.versionErrorf(lit, go1_13, "binary literals")
|
||||
check.versionErrorf(lit, go1_13, "binary literal")
|
||||
return
|
||||
}
|
||||
if radix == 'o' || radix == 'O' {
|
||||
check.versionErrorf(lit, go1_13, "0o/0O-style octal literals")
|
||||
check.versionErrorf(lit, go1_13, "0o/0O-style octal literal")
|
||||
return
|
||||
}
|
||||
if lit.Kind != syntax.IntLit && (radix == 'x' || radix == 'X') {
|
||||
check.versionErrorf(lit, go1_13, "hexadecimal floating-point literals")
|
||||
check.versionErrorf(lit, go1_13, "hexadecimal floating-point literal")
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -205,7 +205,7 @@ func (x *operand) convertibleTo(check *Checker, T Type, cause *string) bool {
|
||||
// check != nil
|
||||
if cause != nil {
|
||||
// TODO(gri) consider restructuring versionErrorf so we can use it here and below
|
||||
*cause = "conversion of slices to arrays requires go1.20 or later"
|
||||
*cause = "conversion of slice to array requires go1.20 or later"
|
||||
}
|
||||
return false
|
||||
}
|
||||
@ -217,7 +217,7 @@ func (x *operand) convertibleTo(check *Checker, T Type, cause *string) bool {
|
||||
}
|
||||
// check != nil
|
||||
if cause != nil {
|
||||
*cause = "conversion of slices to array pointers requires go1.17 or later"
|
||||
*cause = "conversion of slice to array pointer requires go1.17 or later"
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
@ -60,7 +60,7 @@ func (check *Checker) langCompat(lit *ast.BasicLit) {
|
||||
}
|
||||
// len(s) > 2
|
||||
if strings.Contains(s, "_") {
|
||||
check.versionErrorf(lit, go1_13, "underscores in numeric literals")
|
||||
check.versionErrorf(lit, go1_13, "underscore in numeric literal")
|
||||
return
|
||||
}
|
||||
if s[0] != '0' {
|
||||
@ -68,15 +68,15 @@ func (check *Checker) langCompat(lit *ast.BasicLit) {
|
||||
}
|
||||
radix := s[1]
|
||||
if radix == 'b' || radix == 'B' {
|
||||
check.versionErrorf(lit, go1_13, "binary literals")
|
||||
check.versionErrorf(lit, go1_13, "binary literal")
|
||||
return
|
||||
}
|
||||
if radix == 'o' || radix == 'O' {
|
||||
check.versionErrorf(lit, go1_13, "0o/0O-style octal literals")
|
||||
check.versionErrorf(lit, go1_13, "0o/0O-style octal literal")
|
||||
return
|
||||
}
|
||||
if lit.Kind != token.INT && (radix == 'x' || radix == 'X') {
|
||||
check.versionErrorf(lit, go1_13, "hexadecimal floating-point literals")
|
||||
check.versionErrorf(lit, go1_13, "hexadecimal floating-point literal")
|
||||
}
|
||||
}
|
||||
|
||||
|
18
src/internal/types/testdata/check/go1_12.go
vendored
18
src/internal/types/testdata/check/go1_12.go
vendored
@ -10,18 +10,18 @@ package p
|
||||
|
||||
// numeric literals
|
||||
const (
|
||||
_ = 1_000 // ERROR "underscores in numeric literals requires go1.13 or later"
|
||||
_ = 0b111 // ERROR "binary literals requires go1.13 or later"
|
||||
_ = 0o567 // ERROR "0o/0O-style octal literals requires go1.13 or later"
|
||||
_ = 1_000 // ERROR "underscore in numeric literal requires go1.13 or later"
|
||||
_ = 0b111 // ERROR "binary literal requires go1.13 or later"
|
||||
_ = 0o567 // ERROR "0o/0O-style octal literal requires go1.13 or later"
|
||||
_ = 0xabc // ok
|
||||
_ = 0x0p1 // ERROR "hexadecimal floating-point literals requires go1.13 or later"
|
||||
_ = 0x0p1 // ERROR "hexadecimal floating-point literal requires go1.13 or later"
|
||||
|
||||
_ = 0B111 // ERROR "binary"
|
||||
_ = 0O567 // ERROR "octal"
|
||||
_ = 0Xabc // ok
|
||||
_ = 0X0P1 // ERROR "hexadecimal floating-point"
|
||||
_ = 0b111 // ERROR "binary"
|
||||
_ = 0o567 // ERROR "octal"
|
||||
_ = 0xabc // ok
|
||||
_ = 0x0p1 // ERROR "hexadecimal floating-point"
|
||||
|
||||
_ = 1_000i // ERROR "underscores"
|
||||
_ = 1_000i // ERROR "underscore"
|
||||
_ = 0b111i // ERROR "binary"
|
||||
_ = 0o567i // ERROR "octal"
|
||||
_ = 0xabci // ERROR "hexadecimal floating-point"
|
||||
|
@ -8,18 +8,18 @@ package p
|
||||
|
||||
// numeric literals
|
||||
const (
|
||||
_ = 1_000 // ERROR "underscores in numeric literals requires go1.13 or later \(-lang was set to go1.12; check go.mod\)|requires go1.13"
|
||||
_ = 0b111 // ERROR "binary literals requires go1.13 or later"
|
||||
_ = 0o567 // ERROR "0o/0O-style octal literals requires go1.13 or later"
|
||||
_ = 1_000 // ERROR "underscore in numeric literal requires go1.13 or later \(-lang was set to go1.12; check go.mod\)|requires go1.13"
|
||||
_ = 0b111 // ERROR "binary literal requires go1.13 or later"
|
||||
_ = 0o567 // ERROR "0o/0O-style octal literal requires go1.13 or later"
|
||||
_ = 0xabc // ok
|
||||
_ = 0x0p1 // ERROR "hexadecimal floating-point literals requires go1.13 or later"
|
||||
_ = 0x0p1 // ERROR "hexadecimal floating-point literal requires go1.13 or later"
|
||||
|
||||
_ = 0B111 // ERROR "binary"
|
||||
_ = 0O567 // ERROR "octal"
|
||||
_ = 0Xabc // ok
|
||||
_ = 0X0P1 // ERROR "hexadecimal floating-point"
|
||||
_ = 0b111 // ERROR "binary"
|
||||
_ = 0o567 // ERROR "octal"
|
||||
_ = 0xabc // ok
|
||||
_ = 0x0p1 // ERROR "hexadecimal floating-point"
|
||||
|
||||
_ = 1_000i // ERROR "underscores"
|
||||
_ = 1_000i // ERROR "underscore"
|
||||
_ = 0b111i // ERROR "binary"
|
||||
_ = 0o567i // ERROR "octal"
|
||||
_ = 0xabci // ERROR "hexadecimal floating-point"
|
||||
|
Loading…
x
Reference in New Issue
Block a user