-
Notifications
You must be signed in to change notification settings - Fork 244
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Self referential struct crashes nargo process #3490
Comments
Backtrace:
|
We'll need a test in the frontend to prevent constructing recursive types. This can be done when defining a new struct type. |
5 tasks
Current approach:
|
The given test case is currently failing with: error: Nested slices are not supported
┌─ /Users/michaelklein/Coding/rust/noir/test_programs/compile_failure/self_referential_struct/src/main.nr:1:1
│
1 │ ╭ struct SelfReferential
2 │ │ {
3 │ │ prop : [SelfReferential]
4 │ │ }
│ ╰─' Try to use a constant sized array instead
│ Using the following results in a stack overflow: struct SelfReferential
{
prop : Option<SelfReferential>
}
#[test]
unconstrained
fn test_self_referential()
{
let self_ref = SelfReferential { prop : Option::none() };
} |
5 tasks
github-merge-queue bot
pushed a commit
that referenced
this issue
Apr 26, 2024
# Description ## Problem\* Resolves #3490 ## Summary\* Directly referencing the current struct within its definition currently fails with a stack overflow. This PR makes it a normal error, by keeping track of the currently-resolving structs and ensuring no field resolves to them. ## Additional Context Mutual recursion is already handled. ## Documentation\* Check one: - [x] No documentation needed. - [ ] Documentation included in this PR. - [ ] **[For Experimental Features]** 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: jfecher <[email protected]> Co-authored-by: Tom French <[email protected]>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Aim
To create a self referential struct in a slice member
and use it in a test
Expected Behavior
Should work as intended.
Bug
Nargo process crashes during test execution
Testing test_self_referential... thread 'main' has overflowed its stack fatal runtime error: stack overflow
To Reproduce
nargo test
Installation Method
Binary
Nargo Version
0.19.2+d7f919dcc001080ed24616ebbc37426ef7ac7638
Additional Context
No response
Would you like to submit a PR for this Issue?
No
Support Needs
No response
The text was updated successfully, but these errors were encountered: