-
Notifications
You must be signed in to change notification settings - Fork 18.5k
Description
Go Programming Experience
Experienced
Other Languages Experience
No response
Related Idea
- Has this idea, or one like it, been proposed before?
- Does this affect error handling?
- Is this about generics?
- Is this change backward compatible? Breaking the Go 1 compatibility guarantee is a large cost and requires a large benefit
Has this idea, or one like it, been proposed before?
No.
Does this affect error handling?
No.
Is this about generics?
Yes.
It removes a restriction currently present for type parameters.
Proposal
Per the spec:
Within a type parameter list of a generic type
T, a type constraint may not (directly, or indirectly through the type parameter list of another generic type) refer toT.
It seems that we should be able to remove this restriction. The respective examples don't seem to cause problems for the type checker anymore, at tip, now that issue #68162 has been addressed.
Language Spec Changes
No response
Informal Change
No response
Is this change backward compatible?
Yes.
Orthogonality: How does this change interact or overlap with existing features?
This feature will simply remove a restriction.
It may interact with other possible cycles (to be investigated).
Would this change make Go easier or harder to learn, and why?
It would make Go easier to learn because there's fewer rules.
Cost Description
Currently, the type checker doesn't enforce this restriction anymore, so the implementation cost appears to be zero at the moment but for additional tests.
That said, we may uncover as of yet unknown errors due to cycles that were not possible without this change.
Changes to Go ToolChain
Should be minimal because the relevant existing tools rely on the output produced by the type checker.
Performance Costs
There's no compile time cost. The implementation removed an extremely cheap 'if' statement.
Prototype
See fix for #68162.
Metadata
Metadata
Assignees
Labels
Type
Projects
Status