-
Notifications
You must be signed in to change notification settings - Fork 206
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Track graphs of item dependencies to find dependency cycles (#4266)
# Description ## Problem\* Resolves #1122 ## Summary\* Adds a dependency graph to catch cases where structs will cyclically depend on one other. For example, the program: ```rs struct Foo { bar: Bar, } struct Bar { foo: Foo, } ``` Will now give the following error: ``` error: Dependency cycle found ┌─ /home/user/Code/Noir/noir/short/src/main.nr:6:1 │ 6 │ ╭ struct Bar { 7 │ │ foo: Foo, 8 │ │ } │ ╰─' 'Bar' recursively depends on itself: Bar -> Foo -> Bar │ ``` The error is still issued if these are split across separate modules. ## Additional Context Note that self-referential structs like `struct Foo { foo: Foo }` are not currently caught - we may need a separate check for this. This error is also only currently possible for cyclic struct dependencies, but once this is merged I'm going to expand this to more PRs to allow for globals and type aliases as well. This would implement #1734 as well as a similar feature to allow type aliases to reference other type aliases which is currently disallowed. ## Documentation\* Check one: - [x] No documentation needed. - [ ] Documentation included in this PR. - [ ] **[Exceptional Case]** Documentation to be submitted in a separate PR. # PR Checklist\* - [x] I have tested the changes locally. - [x] I have formatted the changes with [Prettier](https://prettier.io/) and/or `cargo fmt` on default settings. --------- Co-authored-by: kevaundray <[email protected]>
- Loading branch information
1 parent
bdd8a96
commit 61eabf1
Showing
11 changed files
with
259 additions
and
36 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.