Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

x/tools/go/analysis/passes/stdversion: language vs toolchain version #68246

Open
dominikh opened this issue Jun 28, 2024 · 1 comment
Open

x/tools/go/analysis/passes/stdversion: language vs toolchain version #68246

dominikh opened this issue Jun 28, 2024 · 1 comment
Labels
NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. Tools This label describes issues relating to any tools in the x/tools repository.
Milestone

Comments

@dominikh
Copy link
Member

In this example

-- go.mod --
module example.com

go 1.23
-- foo.go --
//go:build go1.21

package pkg

import "reflect"

func main() {
	_ = reflect.TypeFor[int]
}

stdversion reports ./foo.go:8:14: reflect.TypeFor requires go1.22 or later (file is go1.21)

I believe that this might be overly strict. Even though the //go:build directive downgrades the language version available in the file, it doesn't change the fact that this file will only be built by a toolchain that is at least verison 1.23, because the module as a whole will only be built by a toolchain that satisfies the go dependency in go.mod.

I thus believe that the standard library available to a file with a build tag is max(file's version, module's version), and not min.

/cc @adonovan

@gopherbot gopherbot added the Tools This label describes issues relating to any tools in the x/tools repository. label Jun 28, 2024
@gopherbot gopherbot added this to the Unreleased milestone Jun 28, 2024
@thanm thanm added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Jul 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. Tools This label describes issues relating to any tools in the x/tools repository.
Projects
None yet
Development

No branches or pull requests

4 participants