loader: enforce Go language version in the type checker

This means for example that ranging over integers will only work when
setting the Go version to go1.22 or later in the go.mod file.
Этот коммит содержится в:
Ayke van Laethem 2024-01-18 20:05:14 +01:00
родитель 53db436a7d
коммит 08ca1d13d0
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: E97FF5335DFDFDED

Просмотреть файл

@ -378,6 +378,12 @@ func (p *Package) Check() error {
typeErrors = append(typeErrors, err)
}
checker.Importer = p
if p.Module.GoVersion != "" {
// Setting the Go version for a module makes sure the type checker
// errors out on language features not supported in that particular
// version.
checker.GoVersion = "go" + p.Module.GoVersion
}
// Do typechecking of the package.
packageName := p.ImportPath