You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Within standard library packages the GoVersion sent to unitchecker is "" for standard library packages. This can be recreated from gotip vet -x ./... from $GOROOT/src (which will be in a module).
This GoVersion is passed along to go/types in types.Config. When this is empty (which is an invalid version), (*types.Info).FileVersions is not populated. The loopclosure vet check uses FileVersions to decide what is the semantics of a given for loop is. So there will now be a divergence in behavior for cmd/vet when running on the standard libraries.
The relevant code to set the field is in buildVetConfig:
if a.Package.Module != nil {
v := a.Package.Module.GoVersion
if v == "" {
v = gover.DefaultGoModVersion
}
vcfg.GoVersion = "go" + v
}
A hunch for why a.Package.Module is nil is that it comes from PackageModuleInfo which documents that nil is expected:
// PackageModuleInfo returns information about the module that provides
// a given package. If modules are not enabled or if the package is in the
// standard library or if the package was not successfully loaded with
// LoadPackages or ImportFromFiles, nil is returned.
func PackageModuleInfo(ctx context.Context, pkgpath string) *modinfo.ModulePublic {
Within standard library packages the GoVersion sent to unitchecker is "" for standard library packages. This can be recreated from
gotip vet -x ./...
from$GOROOT/src
(which will be in a module).This
GoVersion
is passed along togo/types
intypes.Config
. When this is empty (which is an invalid version),(*types.Info).FileVersions
is not populated. Theloopclosure
vet check usesFileVersions
to decide what is the semantics of a given for loop is. So there will now be a divergence in behavior for cmd/vet when running on the standard libraries.The relevant code to set the field is in
buildVetConfig
:A hunch for why
a.Package.Module
is nil is that it comes fromPackageModuleInfo
which documents that nil is expected:cc @bcmills
The text was updated successfully, but these errors were encountered: