spec: restriction on self-referential types does not match accepted proposal #63149
Labels
compiler/runtime
Issues related to the Go compiler and/or runtime.
generics
Issue is related to generics
NeedsInvestigation
Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone
What did you do?
Write Go programs corresponding to the interfaces illustrated in Fig. 5 and Fig. 7 of Featherweight Go:
Figure 5: https://go.dev/play/p/pkXtATz0zJW?v=gotip
Figure 7: https://go.dev/play/p/w1ULe7lazaT?v=gotip
What did you expect to see?
Behavior per the design described in https://go.dev/design/43651-type-parameters and accepted in #43651:
Or, an accepted proposal modifying the design, including a discussion of the tradeoffs involved.
What did you see instead?
invalid recursive type
errors.It appears that what was actually implemented (and what is described in the current spec) does not match what was accepted in the proposal. The spec text was changed to:
That breaks the examples from Figure 5 and Figure 7 of the paper, and results in an implementation of type parameters weaker than what was proposed.
For comparison, if the type parameters are removed, both figures compile:
Figure 5 (parameter removed from
Eq
): https://go.dev/play/p/DKHGVraxMRX?v=gotipFigure 7 (parameters removed from
Edge
andVertex
): https://go.dev/play/p/YVxG0BOQgqm?v=gotip(CC @ianlancetaylor @griesemer)
The text was updated successfully, but these errors were encountered: