mirror of
https://github.com/tinygo-org/tinygo.git
synced 2026-07-26 06:38:42 +00:00
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.
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user