This makes version.go holding core version checking code only.
No functional changes.
Change-Id: Ia88a48166cad2698765697dd7a8625b56ecc2226
Reviewed-on: https://go-review.googlesource.com/c/go/+/567536
Reviewed-by: Robert Griesemer <gri@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Robert Findley <rfindley@google.com>
Auto-Submit: Robert Griesemer <gri@google.com>
"go/constant"
"go/token"
. "internal/types/errors"
+ "strings"
)
/*
}
}
+// langCompat reports an error if the representation of a numeric
+// literal is not compatible with the current language version.
+func (check *Checker) langCompat(lit *syntax.BasicLit) {
+ s := lit.Value
+ if len(s) <= 2 || check.allowVersion(check.pkg, lit, go1_13) {
+ return
+ }
+ // len(s) > 2
+ if strings.Contains(s, "_") {
+ check.versionErrorf(lit, go1_13, "underscore in numeric literal")
+ return
+ }
+ if s[0] != '0' {
+ return
+ }
+ radix := s[1]
+ if radix == 'b' || radix == 'B' {
+ check.versionErrorf(lit, go1_13, "binary literal")
+ return
+ }
+ if radix == 'o' || radix == 'O' {
+ 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 literal")
+ }
+}
+
// exprInternal contains the core of type checking of expressions.
// Must only be called by rawExpr.
// (See rawExpr for an explanation of the parameters.)
"fmt"
"go/version"
"internal/goversion"
- "strings"
)
// A goVersion is a Go language version string of the form "go1.%d"
go_current = asGoVersion(fmt.Sprintf("go1.%d", goversion.Version))
)
-// langCompat reports an error if the representation of a numeric
-// literal is not compatible with the current language version.
-func (check *Checker) langCompat(lit *syntax.BasicLit) {
- s := lit.Value
- if len(s) <= 2 || check.allowVersion(check.pkg, lit, go1_13) {
- return
- }
- // len(s) > 2
- if strings.Contains(s, "_") {
- check.versionErrorf(lit, go1_13, "underscore in numeric literal")
- return
- }
- if s[0] != '0' {
- return
- }
- radix := s[1]
- if radix == 'b' || radix == 'B' {
- check.versionErrorf(lit, go1_13, "binary literal")
- return
- }
- if radix == 'o' || radix == 'O' {
- 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 literal")
- }
-}
-
// allowVersion reports whether the given package is allowed to use version v.
func (check *Checker) allowVersion(pkg *Package, at poser, v goVersion) bool {
// We assume that imported packages have all been checked,
"go/internal/typeparams"
"go/token"
. "internal/types/errors"
+ "strings"
)
/*
}
}
+// langCompat reports an error if the representation of a numeric
+// literal is not compatible with the current language version.
+func (check *Checker) langCompat(lit *ast.BasicLit) {
+ s := lit.Value
+ if len(s) <= 2 || check.allowVersion(check.pkg, lit, go1_13) {
+ return
+ }
+ // len(s) > 2
+ if strings.Contains(s, "_") {
+ check.versionErrorf(lit, go1_13, "underscore in numeric literal")
+ return
+ }
+ if s[0] != '0' {
+ return
+ }
+ radix := s[1]
+ if radix == 'b' || radix == 'B' {
+ check.versionErrorf(lit, go1_13, "binary literal")
+ return
+ }
+ if radix == 'o' || radix == 'O' {
+ 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 literal")
+ }
+}
+
// exprInternal contains the core of type checking of expressions.
// Must only be called by rawExpr.
// (See rawExpr for an explanation of the parameters.)
"go/token"
"go/version"
"internal/goversion"
- "strings"
)
// A goVersion is a Go language version string of the form "go1.%d"
go_current = asGoVersion(fmt.Sprintf("go1.%d", goversion.Version))
)
-// langCompat reports an error if the representation of a numeric
-// literal is not compatible with the current language version.
-func (check *Checker) langCompat(lit *ast.BasicLit) {
- s := lit.Value
- if len(s) <= 2 || check.allowVersion(check.pkg, lit, go1_13) {
- return
- }
- // len(s) > 2
- if strings.Contains(s, "_") {
- check.versionErrorf(lit, go1_13, "underscore in numeric literal")
- return
- }
- if s[0] != '0' {
- return
- }
- radix := s[1]
- if radix == 'b' || radix == 'B' {
- check.versionErrorf(lit, go1_13, "binary literal")
- return
- }
- if radix == 'o' || radix == 'O' {
- 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 literal")
- }
-}
-
// allowVersion reports whether the given package is allowed to use version v.
func (check *Checker) allowVersion(pkg *Package, at positioner, v goVersion) bool {
// We assume that imported packages have all been checked,