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.
Этот коммит содержится в:
родитель
53db436a7d
коммит
08ca1d13d0
1 изменённых файлов: 6 добавлений и 0 удалений
|
@ -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
|
||||
|
|
Загрузка…
Создание таблицы
Сослаться в новой задаче