icerpc / slicec

The Slice compiler library
Apache License 2.0
13 stars 5 forks source link

Improved Cycle Detection Logic #689

Closed InsertCreativityHere closed 9 months ago

InsertCreativityHere commented 9 months ago

This PR fixes and improves the cycle detection logic. 1) Currently, the detector doesn't check inside of sequences, dictionaries, or results, so struct S { s: Sequence<S> } won't be caught. This PR improves the detector to check these kinds of things.

2) Adds a path for the detector to check enums with fields for cycles. (Currently it does not).

3) It adds logic to avoid outputting duplicate cycles: A -> B -> A and B -> A -> B are really the same cycle, no point in outputting both. We avoid duplicates by storing sets of cycle elements like {A, B}. If we detect a cycle, and it's set of elements has already been reported, we don't report it again.

Fixes #683.