-
Notifications
You must be signed in to change notification settings - Fork 17.9k
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: internal compiler error: invalid memory address or nil pointer dereference #51232
Comments
https://go.dev/play/p/m_EXRkYORl-?v=gotip is similar, but I think it's slightly simpler, but also weirder? At a glance, this second version seems mildly similar to #51219, maybe the fix for it at https://go.dev/cl/386335 applies here (cc @danscales)? It's a bit late though, so I haven't looked into how I could try out that CL directly. |
I made a simpler one, which applies to my code in #51219 too, I'm pretty sure it's related so putting it there https://go.dev/play/p/SI6WD_aSX8I?v=gotip This probably shouldn't compile, but the compiler shouldn't panic (Also tried with the CL, I'm not so sure it's the same issue) Edit: Made another issue, unsure it's actually related to this one, #51236 |
#51219 is related to importing a highly recursive type, so the two failures in this issue are completely separate from that. The two cases appear to be distinct. |
This example is a separate issue from the main one here, and it looks like it is the same as #51236 . So, let's make #51236 the main issue for handling this case (where the error message is something like: "internal compiler error: found illegal assignment main.Foo.UnmarshalJSON.T -> SLICE-[]byte;" |
So I am looking at this, and where I have gotten thus far is that things go bad like so. I do not know why they go bad, only that the result type for the function-typed
|
This comment was marked as duplicate.
This comment was marked as duplicate.
@mpx I moved your case to a new issue - it is distinct. Thanks for providing it! |
@griesemer @findleyr The original test case in this issue (see top issue description, https://go.dev/play/p/V4-OtYakAMj?v=gotip) seems to be a types2 bug (fairly unusual case). It seems like it is probably happening because the type inference that is needed at line 14 is somewhat happening (so there is no typechecker error), but not completely happening, so types2 is returning a nil type to the compiler. What's happening is that when we are noding the
This invalid type turns into a nil type, which causes the compiler crash later on. The entire program compiles and runs (since we get the correct valid type for the call) if we change line 14 from:
to
(I.e. add in the RG typeparam so type inference doesn't need to figure it out). |
Haven't read the entire issue, but this looks like a dupe of #51233, or rather seems likely to have the same root cause. |
@findleyr This code requires core type unification that we recently enabled, otherwise it won't type-check. We may have missed something in that code. |
I have not read the spec closely, recently, but is a single parameter instantiation of a two-parameter generic supposed to ever work? I.e. |
@dr2chase Yes, that is supposed to work, using constraint type inference. There's clearly something wrong here on the type checker side. Actively investigating. |
Yes, we run constraint type inference if not all type parameters are supplied. In this example there is a complex interaction of inference with declaration type checking. We are investigating if this can be fixed. |
Change https://go.dev/cl/387918 mentions this issue: |
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
)?N/A
What did you do?
https://go.dev/play/p/V4-OtYakAMj?v=gotip
What did you expect to see?
Some error. Was trying to make a testcase for an inference bug.
What did you see instead?
./prog.go:23:11: internal compiler error: panic: runtime error: invalid memory address or nil pointer dereference
The text was updated successfully, but these errors were encountered: