cmd/compile: internal compiler error: found illegal assignment main.Comp[.shape.[]string_0] -> main.Ordering[.shape.[]string_0]; : main.Comp[.shape.[]string_0] does not implement main.Ordering[.shape.[]string_0] #48889
Labels
Milestone
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
gotip is required for the code to compile.
go 1.17.1 displays the following error instead
(when lowering the module requirement to 1.17):
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
I implemented github.com/abc-inc/goava/collect/ordering, which is heavily inspired by the equivalent
Ordering
of Guava.The function
Lexicographical[T]()
does a pairwise comparison of two arguments of type[]T
, hence it returnsOrdering[[]T]
.When using it in another package, an internal compiler error is occurs.
A stripped down version of the code can be found at https://github.com/gschauer/go-issue-compiler-generics-slice
along with the logs: https://github.com/gschauer/go-issue-compiler-generics-slice/actions
What did you expect to see?
The test should compile and pass, or at least display the actual type of the variable
o
.What did you see instead?
See also: https://github.com/gschauer/go-issue-compiler-generics-slice/actions
Remark
The root cause seems to be a combination of exporting a type with
[]T
ANDusing it in another package.
Executing the code in the corresponding "
_test
" package is sufficient to encounter the issue.As long as the code is used solely inside the very same package, it runs successfully.
The
-G=3
frontend does not match the types.shape.[]string_0
andmain.Comp.Reverse.T
.GOEXPERIMENT=unified
(and-vet=off
) allows to compile and run the code successfully.The text was updated successfully, but these errors were encountered: