-
Notifications
You must be signed in to change notification settings - Fork 18k
[dev.typeparams] internal compiler error: cannot export = (22) node #47514
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
cc @griesemer |
PS: Unified IR does not have this problem. |
Looks like we're trying to export an expression, and come across an OAS. From here: . RETURN tc(1) # issue47514.go:5:3 But, this OAS is only generated during walk. We're then trying to export it, after walk, which doesn't seem right to me. |
@randall77 Yeah, I think the problem is that in I think |
Change https://golang.org/cl/340258 mentions this issue: |
I can confirm that the original case works now, but I have another case that might be related:
results in: # command-line-arguments panic: runtime error: index out of range [1] with length 1 goroutine 1 [running]: cmd/compile/internal/noder.typecheckaste(0xd0, {0xe44468, 0xc0001397c0}, 0x0, 0x8, {0xc00011ee20, 0x1, 0xc00043bef0}, 0x1) /home/enikolov/sdk/gotip/src/cmd/compile/internal/noder/transform.go:511 +0x3d5 cmd/compile/internal/noder.(*irgen).stmt(0xc00015c300, {0xe448e8, 0xc0003ffcc0}) /home/enikolov/sdk/gotip/src/cmd/compile/internal/noder/stmt.go:134 +0xd0b cmd/compile/internal/noder.(*irgen).stmts(0xc000448d20, {0xc00011ebd0, 0x1, 0xbd3578}) /home/enikolov/sdk/gotip/src/cmd/compile/internal/noder/stmt.go:18 +0xaf cmd/compile/internal/noder.(*irgen).funcBody(0xc00015c300, 0xc000446dc0, 0xc00043be00, 0xc000139740, 0xc000139780) /home/enikolov/sdk/gotip/src/cmd/compile/internal/noder/func.go:46 +0x25e cmd/compile/internal/noder.(*irgen).funcLit(0xc00015c300, {0xe43800, 0xc000139bc0}, 0xc0003ffca0) /home/enikolov/sdk/gotip/src/cmd/compile/internal/noder/expr.go:456 +0xe8 cmd/compile/internal/noder.(*irgen).expr0(0xc00015c300, {0xe43800, 0xc000139bc0}, {0xe44678, 0xc0003ffca0}) /home/enikolov/sdk/gotip/src/cmd/compile/internal/noder/expr.go:108 +0x905 cmd/compile/internal/noder.(*irgen).expr(0xc00015c300, {0xe44678, 0xc0003ffca0}) /home/enikolov/sdk/gotip/src/cmd/compile/internal/noder/expr.go:79 +0x5d4 cmd/compile/internal/noder.(*irgen).exprs(0x10, {0xc0004593a0, 0x1, 0x403829}) /home/enikolov/sdk/gotip/src/cmd/compile/internal/noder/expr.go:412 +0x8e cmd/compile/internal/noder.(*irgen).exprList(0x0, {0xe44678, 0xc0003ffca0}) /home/enikolov/sdk/gotip/src/cmd/compile/internal/noder/expr.go:395 +0x85 cmd/compile/internal/noder.(*irgen).stmt(0xc00015c300, {0xe44378, 0xc000139800}) /home/enikolov/sdk/gotip/src/cmd/compile/internal/noder/stmt.go:75 +0x3ab cmd/compile/internal/noder.(*irgen).stmts(0xc000448a10, {0xc00011ebe0, 0x1, 0x7f3ac53bf768}) /home/enikolov/sdk/gotip/src/cmd/compile/internal/noder/stmt.go:18 +0xaf cmd/compile/internal/noder.(*irgen).funcBody(0xc00015c300, 0xc000446c60, 0x0, 0xc000139680, 0xc000139700) /home/enikolov/sdk/gotip/src/cmd/compile/internal/noder/func.go:46 +0x25e cmd/compile/internal/noder.(*irgen).funcDecl(0xc00015c300, 0xc000459788, 0xc000137b60) /home/enikolov/sdk/gotip/src/cmd/compile/internal/noder/decl.go:108 +0x26f cmd/compile/internal/noder.(*irgen).decls(0xc00015c300, {0xc0003ffea0, 0x2, 0xc00043bae0}) /home/enikolov/sdk/gotip/src/cmd/compile/internal/noder/decl.go:28 +0x152 cmd/compile/internal/noder.(*irgen).generate(0xc00015c300, {0xc00011eb40, 0x2, 0x203000}) /home/enikolov/sdk/gotip/src/cmd/compile/internal/noder/irgen.go:232 +0x4b9 cmd/compile/internal/noder.check2({0xc00011eb40, 0x2, 0x2}) /home/enikolov/sdk/gotip/src/cmd/compile/internal/noder/irgen.go:92 +0x16d cmd/compile/internal/noder.LoadPackage({0xc00013a120, 0x2, 0x0}) /home/enikolov/sdk/gotip/src/cmd/compile/internal/noder/noder.go:90 +0x365 cmd/compile/internal/gc.Main(0xd135c0) /home/enikolov/sdk/gotip/src/cmd/compile/internal/gc/main.go:190 +0xaf3 main.main() /home/enikolov/sdk/gotip/src/cmd/compile/main.go:55 +0xdd It seems to happen when there is a list of returned types, at least one of which is parameterized. |
Yes, thanks for the original case and the new case! I'm aware of the issue of the new case, which relates to the use of multiple return values in generic calls. The original case is mainly related to closures in generic functions, so they are largely unrelated. I'll leave the issue open for the second case, which I'm still working on the cleanest way to fix. |
… are not compiled Closures inside generic functions were being added to the g.target.Decls list during noding, just like other closures. We remove generic functions/methods from g.target.Decls, so they don't get compiled (they're only available for export and stenciling). Most closures inside generic functions/methods were similarly being removed from g.target.Decls, because they have a generic parameter. But we need to ensure no closures in generic function/methods are left remaining in g.target.Decls, since we don't want them transformed and compiled. So, we set a flag in (*irgen) that records when we are noding a top-level generic function/method, and don't add any closures to g.target.Decls when the flag is true. Updates #47514 Change-Id: Id66b4c41d307ffa8f54cab6ce3646ade81606862 Reviewed-on: https://go-review.googlesource.com/c/go/+/340258 Trust: Dan Scales <[email protected]> Reviewed-by: Keith Randall <[email protected]>
Change https://golang.org/cl/340531 mentions this issue: |
Another case:
If I move the type assertion .(T) to the previous line, it works fine, so it seems that it only fails in case of type assertions in the argument of a function call |
And another similar case but with a different error:
|
Let me know if listsing those cases here is fine, or if I should create separate issues. |
And another one: https://github.com/e-nikolov/go-generics-issues/tree/master/issue5 // main.go
package main
import "github.com/e-nikolov/go-generics-issues/issue5/pkg"
func Do[T any](doer pkg.Doer[T]) {
doer.Do()
}
func main() {
}
// pkg/doer.go
package pkg
type Doer[T any] interface {
Do() T
} results in:
|
…ckaste in noder In the cases where we do an early call to typecheckaste() in noder to expose CONVIFACE nodes, we need a preceding call to transformArgs(). This is needed to allow typecheckaste() to run correctly, in the case of f(g()), where g has multiple return values. I also cleaned up the code a bit and commented the code in Call(), and we do the call to typecheckaste() in several more cases. In stencil.go:stencil(), I moved the transformCall earlier for the OCALLMETH/ODOTMETH case, just as I did in my previous CL for OCALL/OFUNCINST. By doing this, transformArgs no longer needs to deal with the extra dictionary args. Therefore, I was able to simply transformArgs() to look like typecheckargs() again, and make use of RewriteMultiValue directly. Updates #47514 Change-Id: I49eb82ac05707e50c2e2fb03e39458a70491d406 Reviewed-on: https://go-review.googlesource.com/c/go/+/340531 Trust: Dan Scales <[email protected]> Run-TryBot: Dan Scales <[email protected]> TryBot-Result: Go Bot <[email protected]> Reviewed-by: Keith Randall <[email protected]>
Thanks for the three new cases, @e-nikolov ! I'll update this issue as I have time to triage and/or fix each case. |
I believe this case (your 2nd-to-last example) was fixed by https://go-review.googlesource.com/c/go/+/342989 by Keith. I still need to investigate the last and 3rd-to-last examples. |
Change https://golang.org/cl/345411 mentions this issue: |
I believe all your cases are fixed. My just checked-in change fixes the last case you added, and the 3rd to last case that you added (the mayCall error) was fixed by https://go-review.googlesource.com/c/go/+/344571 Feel free to create a new issue if one of these still doesn't seem to work, or you find a new case that doesn't work. |
What version of Go are you using (
go version
)?What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
I tried to compile the following program
using
gotip run -gcflags=all=-G=3 main.go
What did you expect to see?
I expected it to compile
What did you see instead?
The text was updated successfully, but these errors were encountered: