-
Notifications
You must be signed in to change notification settings - Fork 229
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
Compiler panic when you initialize a slice of composite type with as value, a slice with the exact same type. #4742
Comments
This looks to be due to incorrect array to slice coercion @jfecher. let var1: [(i32, u8)] = [(1, 2)];
let var2: [(i32, u8)] = var1; I get:
We look to be expecting an array when checking an AsSlice call, but we have two arguments and are calling as_slice on a slice. |
Looks like a result of IIRC this used to return the annotated type. I don't remember why it was changed a while back. |
I'll test that out |
Looks to be a part of this PR (#4152). I'm assuming the simpler logic was fine until this case |
Switching it back fixes the issue |
# Description ## Problem\* Resolves #4742 ## Summary\* ## Additional Context ## Documentation\* Check one: - [ ] No documentation needed. - [ ] Documentation included in this PR. - [ ] **[For Experimental Features]** Documentation to be submitted in a separate PR. # PR Checklist\* - [ ] I have tested the changes locally. - [ ] I have formatted the changes with [Prettier](https://prettier.io/) and/or `cargo fmt` on default settings.
Aim
We (https://github.com/FuzzingLabs) found that the compiler panics when you initialize a slice of composite type with as value, a slice with the exact same type.
Expected Behavior
No panic should occur.
Bug
The previous issue reported shows that modifying a slice causes the compiler to panic. However, this issue demonstrates that initializing a slice of a composite type with another slice of the same type as its value also triggers a compiler panic.
The specific composite type or values used are irrelevant. The issue arises only when assigning an existing slice as the value of the initialized slice. If the value is a slice created within the initialization statement, the panic does not occur.
The issue seems to be due to the compiler treating the slice as an array and attempting to call AsSlice on it. However, the slice doesn’t have a fixed size like an array.
The issue occurs with the latest compiler version on the master branch. The error message is as follows:
To Reproduce
Project Impact
None
Impact Context
No response
Workaround
None
Workaround Description
No response
Additional Context
No response
Installation Method
None
Nargo Version
No response
NoirJS Version
No response
Would you like to submit a PR for this Issue?
None
Support Needs
No response
The text was updated successfully, but these errors were encountered: