-
Notifications
You must be signed in to change notification settings - Fork 17.8k
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
go/types: type aliases can lead to invalid types #26390
Comments
It seems like Not a regression from 1.10, but this seems bad enough to warrant consideration for 1.11. I'll leave it to @griesemer and @alandonovan to decide. |
@kjk also, it appears that your instructions to reproduce the issue aren't correct. Now I'm getting errors like:
It looks like you have been pushing commits to your branch. Exactly what commit did you use to get the invalid types? Could you push that code to a completely separate repo that builds on its own? |
@mvdan It must be something on your end. I just re-ran my instructions, on mac, using go 1.10.3:
Notice it builds.
I even have compile-time check that And every revision is compiled and tested on Travis: https://travis-ci.org/kjk/ravendb-go-client |
@kjk Is this still an issue with the latest Go 1.11 release candidate? In your instructions above you mention go1.10.3. We have fixed several alias-related bugs for go 1.11 in go/types (where there would be an issue, if any). |
It's even worse on HEAD in that go HEAD doesn't even compile code that go 1.10.3 was able to compile. In 1.10.3 the problem was limited to Current repro: Checkout https://github.com/kjk/ravendb-go-client/commit/90cab786842d66d12e3cbc8548e95af227235623 (the latest version when I write this).
This is on mac using go I just installed with When you look at the code, And proof that this code compiles with 1.10.3: https://travis-ci.org/kjk/ravendb-go-client/builds/412873534 |
@griesemer thanks for picking this up - it appears I dropped the ball on the investigation. Happy to help review a CL if you end up with one. |
Simple reproducer: package p
type A = T
func (t *T) m() *A { return t }
type T struct{} Calling gotype on this package produces:
On the other hand, if type T is declared first, the error goes away. Investigating. |
@kjk Can you please let me know if |
@griesemer Yes, |
@kjk Thanks for the confirmation. I do have a smallish fix for this in go/types (assuming it gets ok'ed), but it's just a work-around as we can't do the real fix at this point of the release process (the real fix is slated for 1.12). Will post a CL either tonight or tomorrow. |
Change https://golang.org/cl/128435 mentions this issue: |
@kjk If you could verify that the issue is fixed for your build with the latest tip, that would be great. Thanks. |
@griesemer Yes, it works with HEAD. Thanks! |
@kjk Great - thanks for confirming! |
Change https://golang.org/cl/139899 mentions this issue: |
Change https://golang.org/cl/139900 mentions this issue: |
This work-around is not needed anymore now that method signatures are type-checked separately from their receiver base types: no artificial cycles are introduced anymore and so there is no need to artificially cut them. Fixes #26854. Change-Id: I2ef15ceeaa0b486f65f6cdc466d0cf06246c74d7 Reviewed-on: https://go-review.googlesource.com/c/139900 Reviewed-by: Alan Donovan <adonovan@google.com>
Necessary for Go 1.11, see golang/go#26390.
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
Yes.
What operating system and processor architecture are you using (
go env
)?What did you do?
What did you expect to see?
This is a valid program that compiles.
go vet
should not complain.What did you see instead?
go vet
complaints.Those errors are due to using
type Foo = Bar
aliases. Thoseinvalid
types are type aliases.I know that using type aliases is bad style. Not handling them is still a bug.
I tried to minimize the repro but I failed to create a small example so I'm showing the whole code.
I assume this is a problem with
ast
package because other tools break on this codebase as well, likerename symbol
functionality in Visual Studio Code.The text was updated successfully, but these errors were encountered: