Fixed Cycle Detection Logic and Added Tests. #524
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR does a couple few things:
Fixes the logic for detecting cyclic container types (structs and exceptions) because the current logic is totally broken.
A Slice definition like
struct S { s: S }
causes a stack overflow. This is no longer the case with these new changes.Fixes the logic for reporting cyclic type aliases. It incorrectly reports cycles like: 'Foo -> B -> A -> B'.
Even though
Foo
isn't part of the cycle, it gets reported like it is.Simplifies the error reporting logic for cyclic type aliases. We go out of our way to emit very detailed messages about each link in a cycle. Now we just report the cycle like: 'A -> B -> C -> A'. I think that's good enough, and made it easy to implement the above mentioned fix.
Implements Add tests for
InfiniteSizeCycle
andCannotResolveDueToCycles
#386 and finishes implementing Add Detection/Validation/Tests for Catching Cyclic Type-Aliases #181 by adding tests for cycle detection of both type-aliases and containers.