TP0230
Error: recursive type alias
Messages
Section titled “Messages”type alias '<A>' refers to itselftype alias '<A>' refers to itself through '<B>'('<B>' and '<C>'for longer cycles), with helpuse a class for a recursive type(M18)
Example
Section titled “Example”From the golden case tests/cases/m18/tp0230_recursive.tpn:
# Recursive aliases (SPEC §3.12): each cycle is reported once, at its first alias.type Tree = list[Tree]type A = list[B]type B = A?type UsesCycle = list[A]type X = dict[str, Y]type Y = tuple[Z, int]type Z = X
# A class refers to itself without expanding.@dataclassclass Node: children: list[Node]
let t: Tree = []let u: UsesCycle = []print(Node([]))The compiler reports:
tp0230_recursive.tpn:2:6: error TP0230: type alias 'Tree' refers to itself help: use a class for a recursive typetp0230_recursive.tpn:3:6: error TP0230: type alias 'A' refers to itself through 'B' help: use a class for a recursive typetp0230_recursive.tpn:6:6: error TP0230: type alias 'X' refers to itself through 'Y' and 'Z' help: use a class for a recursive typeThe specification lists every code.
© 2026 Discover Edge, LLC · Taipan is released under the MIT License.