Skip to content

Commit

Permalink
go/internal/gcimporter: bump version number in skew check
Browse files Browse the repository at this point in the history
This constant controls the "version skew" warning printed
in case of panic, but doesn't control the version that is
actually accepted, which is currently v2.

Also, clarify meaning of 'path' parameter. The subtle
difference between "package path" (linker symbol prefix,
which may have "vendor/" prefix) and "import path" (string
literal appearing in import declaration, sans "vendor/")
is a pervasive source of bugs in gopls' handling of vendored
packages.

Change-Id: I8c3001a23b84abb1f18d861e01334bb3f0a5c27a
Reviewed-on: https://go-review.googlesource.com/c/tools/+/444537
gopls-CI: kokoro <noreply+kokoro@google.com>
Run-TryBot: Alan Donovan <adonovan@google.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Auto-Submit: Alan Donovan <adonovan@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
  • Loading branch information
adonovan committed Oct 20, 2022
1 parent 65196ca commit 207f456
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
6 changes: 5 additions & 1 deletion go/gcexportdata/gcexportdata.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,11 @@ func NewReader(r io.Reader) (io.Reader, error) {

// Read reads export data from in, decodes it, and returns type
// information for the package.
// The package name is specified by path.
//
// The package path (effectively its linker symbol prefix) is
// specified by path, since unlike the package name, this information
// may not be recorded in the export data.
//
// File position information is added to fset.
//
// Read may inspect and add to the imports map to ensure that references
Expand Down
4 changes: 3 additions & 1 deletion go/internal/gcimporter/iimport.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ const (
iexportVersionPosCol = 1
iexportVersionGo1_18 = 2
iexportVersionGenerics = 2

iexportVersionCurrent = 2
)

type ident struct {
Expand Down Expand Up @@ -96,7 +98,7 @@ func IImportBundle(fset *token.FileSet, imports map[string]*types.Package, data
}

func iimportCommon(fset *token.FileSet, imports map[string]*types.Package, data []byte, bundle bool, path string) (pkgs []*types.Package, err error) {
const currentVersion = 1
const currentVersion = iexportVersionCurrent
version := int64(-1)
if !debug {
defer func() {
Expand Down

0 comments on commit 207f456

Please sign in to comment.