Skip to content

x/tools/gopls/internal/analyze/modernize: rangeint: transformation introduces invalid type #73037

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

Closed
adonovan opened this issue Mar 25, 2025 · 2 comments
Labels
BugReport Issues describing a possible bug in the Go implementation. gopls Issues related to the Go language server, gopls.
Milestone

Comments

@adonovan
Copy link
Member

The rangeint modernizer introduces bad type syntax when it decides the for-loop's limit expression requires an explicit conversion:

package mlkem

func TestFieldAdd(t *testing.T) {
	for a := fieldElement(0); a < q; a++ {
		for b := fieldElement(0); b < q; b++ {
func TestFieldAdd(t *testing.T) {
	for a := range mlkem.fieldElement(q) { // undefined: mlkem
		for b := range mlkem.fieldElement(q) {

See https://go.dev/cl/659155.

We need better testing.

@gopherbot gopherbot added Tools This label describes issues relating to any tools in the x/tools repository. gopls Issues related to the Go language server, gopls. labels Mar 25, 2025
@gopherbot gopherbot added this to the Unreleased milestone Mar 25, 2025
@adonovan adonovan added BugReport Issues describing a possible bug in the Go implementation. Analysis Issues related to static analysis (vet, x/tools/go/analysis) Refactoring Issues related to refactoring tools labels Mar 25, 2025
@adonovan adonovan modified the milestones: Unreleased, gopls/v0.18.2 Mar 25, 2025
@gopherbot
Copy link
Contributor

Change https://go.dev/cl/660815 mentions this issue: gopls/internal/analysis/modernize: don't add package when conversion type is defined in the same package

@adonovan adonovan added BugReport Issues describing a possible bug in the Go implementation. and removed Tools This label describes issues relating to any tools in the x/tools repository. Analysis Issues related to static analysis (vet, x/tools/go/analysis) Refactoring Issues related to refactoring tools BugReport Issues describing a possible bug in the Go implementation. labels Mar 26, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
BugReport Issues describing a possible bug in the Go implementation. gopls Issues related to the Go language server, gopls.
Projects
None yet
Development

No branches or pull requests

3 participants