Radar · Go · Archive · Week 48 · Nov 24 – 30, 2025
spec: remove cycle restriction for type parameters
Worth knowinglanguage
- What changed
- The restriction that a type constraint may not refer to its own type parameter list is removed.
- Production impact
- The source does not say.
- Try it
- Write a generic type whose constraint refers to its own type parameter and compile.
- Source
- github.com/golang/go/issues/75883
Understand it, then run it
Run it now
// This program demonstrates the cycle restriction that will be removed in a future Go release.
// The commented code below would compile after the change, but currently fails to compile
// with Go 1.27.1 because a type constraint may not refer to its own type parameter list.
package main
import "fmt"
func main() {
fmt.Println("Cycle restriction removed in future Go releases.")
}
/*
// Example of a self‑referencing generic type that is now allowed:
//
// type Node[T any] struct {
// Value T
// Children []Tree[T] // refers to Tree, which refers back to Node
// }
//
// type Tree[T any] struct {
// Root Node[T]
// }
*/
What it printed when we ran it on Go 1.27.1
Cycle restriction removed in future Go releases.
Run sends this program (for Solidity, the contract and its tests) to our own sandbox, where it is compiled and run once, with no network, and what it printed or the test report comes back here. Nothing is kept. Runs are counted per visitor for the day so everyone gets a turn; the details are on the legal page.
Written by gpt-oss-20b from the linked source · claims checked against the sources · archive, not individually reviewed