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

Support Go 1.17 slice-to-array conversion #55

Closed
ainar-g opened this issue Jun 30, 2021 · 5 comments · Fixed by #56
Closed

Support Go 1.17 slice-to-array conversion #55

ainar-g opened this issue Jun 30, 2021 · 5 comments · Fixed by #56

Comments

@ainar-g
Copy link
Contributor

ainar-g commented Jun 30, 2021

$ go version
  go version go1.17beta1 linux/amd64

$ more ./go/tmp/main.go 
  package main

  import (
  	"fmt"
  )

  func main() {
  	s := []int{1, 2, 3, 4}
  	fmt.Println(*(*[4]int)(s))
  }

$ go run ./go/tmp/main.go 
  [1 2 3 4]

$ unparam ./go/tmp/main.go 
  panic: in command-line-arguments.main: cannot convert *t0 ([]int) to *[4]int
  [...]

This is using latest unparam from master. I'm ready to provide any additional details.

@mvdan
Copy link
Owner

mvdan commented Jun 30, 2021

I wonder if simply upgrading the version of x/tools would solve this error, as we use the ssa package.

@ainar-g
Copy link
Contributor Author

ainar-g commented Jun 30, 2021

I've tried upgrading to golang.org/x/tools@v0.1.5-0.20210629191230-72e4d1bb8d47, but it seems to have no effect. And also, nilness, another SSA-based analyser, is panicking as well. I guess it's an upstream issue then?

@mvdan
Copy link
Owner

mvdan commented Jun 30, 2021

Seems like it, yup.

@ainar-g
Copy link
Contributor Author

ainar-g commented Jul 1, 2021

@mvdan, the bug seems to be fixed in golang.org/x/tools. Should I close this issue, or should I wait for the next tag in that module and make a PR updating the dependency?

@mvdan
Copy link
Owner

mvdan commented Jul 1, 2021

I don't have a problem with using x/tools from master; happy to receive a PR to update it.

ainar-g added a commit to ainar-g/unparam that referenced this issue Jul 1, 2021
The commands used were:

    go get golang.org/x/tools@master
    go mod tidy

There are no manual changes.

Fixes mvdan#55.
@mvdan mvdan closed this as completed in #56 Jul 1, 2021
mvdan pushed a commit that referenced this issue Jul 1, 2021
The commands used were:

    go get golang.org/x/tools@master
    go mod tidy

There are no manual changes.

Fixes #55.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants