You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I try to test Go type parameters in all ways that I can, so I checked what defining two type parameters with the same name do. Compiling this code give on my computer error message
# command-line-arguments
./Go-s11-26.go:13:33: T redeclared in this block
/home/kamil/go/src/github.com/KZiemian/Go-s11-26.go:13:19: other declaration of T
./Go-s11-26.go:30:46: cannot infer T (/home/kamil/go/src/github.com/KZiemian/Go-s11-26.go:13:33)
Maybe it is as it should be, but it looks somewhat wrong to me. Someone with bigger expedience should judge it.
Slightly different version of code, also give similar error message.
The text was updated successfully, but these errors were encountered:
The first error looks exactly right. It's saying you declared T twice, at line 13 (19 and 33 are the column numbers).
The second error is kind of spurious, resulting from the fact that the thing you're calling didn't typecheck correctly. That error should probably be suppressed.
@randall77 Does showing full path in "/home/kamil/go/src/github.com/KZiemian/Go-s11-26.go:13:19: other declaration of T" is correct? It feels wrong to me, but this may be just my.
@hopehook I didn't think how correct code would look like. I just tried to test Go1.18beta in every way that I can imagine, even the silly one, and look if something crash/give weird result. I now working through Type Parameters Proposal to find answers to few true problems that I have. This is just byproduct of it.
I see, that sometimes-relative-sometimes-absolute thing is weird.
I can't reproduce by invoking the compiler directly, but I can using go build. It happens with other errors like this also.
package main
func f(x int, x int) {
}
% ~/go1.18beta2/bin/go tool compile tmp1.go
tmp1.go:3:15: x redeclared in this block
tmp1.go:3:8: other declaration of x
% ~/go1.18beta2/bin/go build tmp1.go
# command-line-arguments
./tmp1.go:3:15: x redeclared in this block
/Users/khr/gowork/tmp1.go:3:8: other declaration of x
go env
OutputI try to test Go type parameters in all ways that I can, so I checked what defining two type parameters with the same name do. Compiling this code give on my computer error message
Maybe it is as it should be, but it looks somewhat wrong to me. Someone with bigger expedience should judge it.
Slightly different version of code, also give similar error message.
The text was updated successfully, but these errors were encountered: