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/gopls: modernize misses modernization of 3-way "max" #72733

Open
sbinet opened this issue Mar 7, 2025 · 1 comment
Open

x/tools/gopls: modernize misses modernization of 3-way "max" #72733

sbinet opened this issue Mar 7, 2025 · 1 comment
Labels
gopls Issues related to the Go language server, gopls. ToolProposal Issues describing a requested change to a Go tool or command-line program. Tools This label describes issues relating to any tools in the x/tools repository.
Milestone

Comments

@sbinet
Copy link
Member

sbinet commented Mar 7, 2025

gopls version

$ gopls -v version
Build info
----------
golang.org/x/tools/gopls v0.18.1
    golang.org/x/tools/[email protected] h1:2xJBNzdImS5u/kV/ZzqDLSvlBSeZX+pWY9uKVP7Pask=
    github.com/BurntSushi/[email protected] h1:pxW6RcqyfI9/kWtOwnv/G+AzdKuy2ZrqINhenH4HyNs=
    github.com/google/[email protected] h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
    golang.org/x/exp/[email protected] h1:1xaZTydL5Gsg78QharTwKfA9FY9CZ1VQj6D/AZEvHR0=
    golang.org/x/[email protected] h1:Zb7khfcRGKk+kqfxFaP5tZqCnDZMjC5VtUBs87Hr6QM=
    golang.org/x/[email protected] h1:GGz8+XQP4FvTTrjZPzNKTMFtSXH80RAzG+5ghFPgK9w=
    golang.org/x/[email protected] h1:L2k9GUV2TpQKVRGMjN94qfUMgUwOFimSQ6gipyJIjKw=
    golang.org/x/[email protected] h1:bofq7m3/HAFvbF51jz3Q9wLg3jkvSPuiZu/pD1XwgtM=
    golang.org/x/[email protected] h1:Ja/5gV5a9Vvho3p2NC/T2TtxhHjrWS/2DvCKMvA0a+Y=
    golang.org/x/[email protected] h1:NPGnvPOTgnjBc9HTaUx+nj+EaUYxl5SJOWqaDYGaFYw=
    honnef.co/go/[email protected] h1:4bH5o3b5ZULQ4UrBmP+63W9r7qIkqJClEA9ko5YKx+I=
    mvdan.cc/[email protected] h1:bg91ttqXmi9y2xawvkuMXyvAA/1ZGJqYAEGjXuP0JXU=
    mvdan.cc/xurls/[email protected] h1:lyBNOm8Wo71UknhUs4QTFUNNMyxy2JEIaKKo0RWOh+8=
go: go1.24.1 X:rangefunc

go env

<not relevant>

What did you do?

I ran cmd/modernize on Gonum

What did you see happen?

it modernized this piece of code:

index 1cbb4444..8ed8cd2d 100644
--- a/internal/asm/f32/ge_test.go
+++ b/internal/asm/f32/ge_test.go
@@ -245,14 +245,11 @@ func gerData(m, n, incX, incY int) (x, y, a []float32) {
 	x = make([]float32, m*incX)
 	y = make([]float32, n*incY)
 	a = make([]float32, m*n)
-	ln := len(x)
-	if len(y) > ln {
-		ln = len(y)
-	}
+	ln := max(len(y), len(x))
 	if len(a) > ln {
 		ln = len(a)
 	}

What did you expect to see?

it should (probably) have noticed the 3-way max:

index 1cbb4444..8ed8cd2d 100644
--- a/internal/asm/f32/ge_test.go
+++ b/internal/asm/f32/ge_test.go
@@ -245,14 +245,11 @@ func gerData(m, n, incX, incY int) (x, y, a []float32) {
 	x = make([]float32, m*incX)
 	y = make([]float32, n*incY)
 	a = make([]float32, m*n)
-	ln := len(x)
-	if len(y) > ln {
-		ln = len(y)
-	}
+	ln := max(len(y), len(x), len(a))
- 	if len(a) > ln {
-		ln = len(a)
- 	}

Editor and settings

No response

Logs

No response

@sbinet sbinet added gopls Issues related to the Go language server, gopls. Tools This label describes issues relating to any tools in the x/tools repository. labels Mar 7, 2025
@gopherbot gopherbot added this to the Unreleased milestone Mar 7, 2025
@gabyhelp gabyhelp added the ToolProposal Issues describing a requested change to a Go tool or command-line program. label Mar 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
gopls Issues related to the Go language server, gopls. ToolProposal Issues describing a requested change to a Go tool or command-line program. Tools This label describes issues relating to any tools in the x/tools repository.
Projects
None yet
Development

No branches or pull requests

3 participants