Skip to content

Typealias Cycles Through Anonymous Type Slip Past the Cycle Check #797

Description

@InsertCreativityHere

Direct alias cycles (typealias A = A, A = B; B = A) are correctly caught (E019).
But when an alias references itself through an anonymous type, slicec/src/patchers/type_ref_patcher.rs:258 returns early on the Patched anonymous type without looking inside it, so a cyclic type graph forms (a Sequence whose element resolves back to itself).

The struct/enum cycle detector's guard is keyed on struct/enum identifiers, and this loop contains none, so it never trips — the recursive traversals then loop forever:

Reproduction

module T
typealias A = Sequence<A>

(Dictionary<int32, A> etc. too.) Exit 127.

Fix

In the alias cycle detector, recurse through anonymous Sequence/Dictionary/Result underlying types, tracking visited aliases, and report the cycle instead of looping.

Metadata

Metadata

Labels

slicecRelated to the 'slicec' crate

Type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions