-
Notifications
You must be signed in to change notification settings - Fork 570
Compiler panic at tip Go due to assumption about nil basic types #1011
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
Comments
Admittedly I don't know why GopherJS makes this assumption, but I'll go ahead and guess maybe at the time this code was written UnsafePointer was the only BasicKind that could plausibly be nil? Although it seems like UntypedNil existed even back in Go 1.5.1: https://pkg.go.dev/go/[email protected]#BasicKind ¯\_(ツ)_/¯ CC @neelance who authored 0f211c5. I'd like to better understand what changes with https://golang.org/cl/284052. Is the below correct?
I have a suspicion that to support this change we'll have to do more than just remove the panic, We will probably have new cases of implicit conversions to handle, unless we already do. It's also a bit puzzling to me that |
Sorry, I linked the wrong CL above (will amend): https://golang.org/cl/284052 is the compiler change, https://golang.org/cl/289715 is the go/types port. Yes, the example in #1011 (comment) is one example of what is changing. Note that 'nil' in the following was already reported as untyped nil:
See more at https://golang.org/issue/13061. Here are playground examples illustrating the change (I'm using go2goplay only because it has the new logic; none of this pertains directly to generics): The actual source that causes the panic is here: https://github.com/golang/go/blob/46cb016190389b7e37b21f04e5343a628ca1f662/src/io/multi.go#L72 Here's an error message with more information:
You're right, it's not completely trivial. I assumed it was straightforward because there must have been pre-existing handling for assignments, for example: gopherjs/compiler/expressions.go Line 1120 in bed99a8
Here is more of the panicking stack:
|
Thanks, this is very helpful. I'll try to give this a close look as soon as I can, but unfortunately can't promise this before the weekend. Addendum: my concern over how non-trivial a change this would be was mostly expression of caution. I only recently started working on GopherJS, so its certain corners are still unfamiliar to me. |
Thanks! Really appreciate your help looking into this. CC @griesemer |
Sigh, I feel like supporting Go 1.17 and generics is going to be an adventure… When I test against https://github.com/nevkontakte/gopherjs/tree/go1.16-stdlib-wip (which is slightly ahead of https://github.com/gopherjs/gopherjs/tree/go1.16-stdlib, which is the about-to-land Go 1.16 support) and https://github.com/golang/go master I get a different panic:
@findleyr can you please confirm which branches of GopherJS and Go you've used it your tests? Also, am I even setting it up correctly? |
The panic happens at this line: So I assume it is caused by the same change, just a different instance of it. |
It looks like that panic would have been caused by the same underlying assumption which was invalidated by CL 289715: the type of nil in that expression is types.Typ[UntypedNil]. I suspect that the different panic is an artifact of the changes in go1.16-stdlib-wip, but FTR I tested with Go at exactly CL 289715 (618e3c15bdb5c031ac037e7ad5c1b3791a913226). |
Could you also share which GopherJS commit you were using? |
Oh, sorry, I was at bed99a8 (1.12.3+go1.12) |
Having spent a few hours on this today, this is what I have so far:
|
I believe the problem is fixed now, but please let us know if you run into more corner cases. Thanks! |
Thank you! I really appreciate your working on this. Will let you know if we discovery anything else. |
Gopherjs breaks at
CL 284052CL 289715 in the Go repository, due to an assumption about nil basic types here:gopherjs/compiler/expressions.go
Line 738 in bed99a8
(
t.Kind()
is nowtypes.UntypedNil
)This is reproducible as follows:
This appears to be a case of Hyrum's law -- I'm not aware of documentation stating that a basic nil must be
types.UnsafePointer
, though please let me know if I've missed something.Unless there is evidence that this implicit assumption about nil basic types is widespread, we'd like to land this change in
go/types
for go1.17. It seems like a trivial fix, but I'm not familiar with the gopherjs compiler. Could someone take a look? Thanks.CC @dmitshur
The text was updated successfully, but these errors were encountered: