]> Cypherpunks.ru repositories - gostls13.git/commitdiff
cmd/compile: remove ErrorfVers and base.Flag.Lang hack
authorMatthew Dempsky <mdempsky@google.com>
Thu, 24 Aug 2023 23:17:44 +0000 (16:17 -0700)
committerGopher Robot <gobot@golang.org>
Fri, 25 Aug 2023 16:38:07 +0000 (16:38 +0000)
ErrorfVers used to be used by typecheck to report when new language
functionality was used, but the -lang flag (from go.mod) was set to an
older version. However, all of the callers have been since removed,
now that this is handled by types2.

And for the same reason, we can stop changing base.Flag.Lang. This was
previously a workaround so that the unified frontend could generate
arbitrary IR without upsetting typecheck, at a time when typecheck was
itself a real frontend. Now it's just a glorified desugaring pass.

Change-Id: I1c0316dbfe2e08ba089acd50fdfe20b17176be25
Reviewed-on: https://go-review.googlesource.com/c/go/+/522877
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
Auto-Submit: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: Keith Randall <khr@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

src/cmd/compile/internal/base/print.go
src/cmd/compile/internal/noder/unified.go

index efd70f7cc54c56b41d21efb83d180f4d879b8945..cc36acec4b65080a2bb2959110e88056cbc8c68a 100644 (file)
@@ -146,11 +146,6 @@ func ErrorfAt(pos src.XPos, code errors.Code, format string, args ...interface{}
        }
 }
 
-// ErrorfVers reports that a language feature (format, args) requires a later version of Go.
-func ErrorfVers(lang string, format string, args ...interface{}) {
-       Errorf("%s requires %s or later (-lang was set to %s; check go.mod)", fmt.Sprintf(format, args...), lang, Flag.Lang)
-}
-
 // UpdateErrorDot is a clumsy hack that rewrites the last error,
 // if it was "LINE: undefined: NAME", to be "LINE: undefined: NAME in EXPR".
 // It is used to give better error messages for dot (selector) expressions.
index e534f0b72569e5ad6b0f58a9de51ce3dda5dd0f7..59a353600019b21ac1e05e20818a28d6354523f7 100644 (file)
@@ -5,8 +5,6 @@
 package noder
 
 import (
-       "fmt"
-       "internal/goversion"
        "internal/pkgbits"
        "io"
        "runtime"
@@ -74,13 +72,6 @@ func unified(m posMap, noders []*noder) {
 
        data := writePkgStub(m, noders)
 
-       // We already passed base.Flag.Lang to types2 to handle validating
-       // the user's source code. Bump it up now to the current version and
-       // re-parse, so typecheck doesn't complain if we construct IR that
-       // utilizes newer Go features.
-       base.Flag.Lang = fmt.Sprintf("go1.%d", goversion.Version)
-       types.ParseLangFlag()
-
        target := typecheck.Target
 
        localPkgReader = newPkgReader(pkgbits.NewPkgDecoder(types.LocalPkg.Path, data))