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

cmd/compile: <N> in byte conversion error message #15055

Closed
josharian opened this issue Mar 31, 2016 · 3 comments
Closed

cmd/compile: <N> in byte conversion error message #15055

josharian opened this issue Mar 31, 2016 · 3 comments

Comments

@josharian
Copy link
Contributor

Try to compile _ = []byte("abc", "def").

http://play.golang.org/p/b8yffUjLNq

Result:

too many arguments to conversion to []byte: ([]byte)(<N>)

That error message is unhelpful; it looks like we have an unexpectedly nil Node.

@josharian josharian added this to the Unplanned milestone Mar 31, 2016
@odeke-em
Copy link
Member

@josharian I don't think this bug only happens for []byte, I think it happens for all "collections"/arrays/slices so [] ie []string, []int, []struct. Please see https://play.golang.org/p/c2vPXbl0Ew
or inlined

package main

func main() {
    _ = []int(12, "123", "485")
    _ = []byte("a", "cd")
    _ = []string("af", "be")

    // Ones that pass
    _ = int(15, "a")
    _ = string("n", "e", "w")
    _ = byte("info", "a$ap")
}

when run or compiled gives error

prog.go:4: too many arguments to conversion to []int: ([]int)(<N>)
prog.go:5: too many arguments to conversion to []byte: ([]byte)(<N>)
prog.go:6: too many arguments to conversion to []string: ([]string)(<N>)
prog.go:9: too many arguments to conversion to int: int(15, "a")
prog.go:10: too many arguments to conversion to string: string("n", "e", "w")
prog.go:11: too many arguments to conversion to byte: byte("info", "a$ap")

Notice that the obscure error message only happens when we have []<Type>

@odeke-em
Copy link
Member

I've mailed https://go-review.googlesource.com/25361.

@gopherbot
Copy link

CL https://golang.org/cl/25361 mentions this issue.

@odeke-em odeke-em self-assigned this Aug 1, 2016
@golang golang locked and limited conversation to collaborators Feb 2, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants