-
Notifications
You must be signed in to change notification settings - Fork 220
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
Bug while using a struct containing a slice #606
Comments
This bug is occurring because slices aren't supported in struct declarations yet. This is because currently slices are actually arrays of generic sizes, so Unfortunately, manually making the struct generic over |
is going through the |
Passing the array through to fn id<N, M>(x: [Field; N]) -> [Field; M] {
x
} instead of fn id<N>(x: [Field; N]) -> [Field; N] {
x
} This is something we're actively working on fixing |
Once #620 is merged this code can run without errors once modified to use explicit array sizes. It is worth noting though that this PR's purpose is to implement a new feature, so the old bug that occurs when array slices are used within structs will continue to be present. The workaround once this PR is merged will be to make the sizes explicit: fn main() {
let a = id([1, 2]);
let b = id([1, 2, 3]);
let itWorks1 = MyStruct { data: a };
constrain itWorks1.data[1] == 2;
let itWorks2 = MyStruct { data: b };
constrain itWorks2.data[1] == 2;
let c = [1, 2];
let itAlsoWorks = MyStruct { data: c };
constrain itAlsoWorks.data[1] == 2;
}
fn id<N>(x: [Field; N]) -> [Field; N] {
x
}
struct MyStruct<N> {
data: [Field; N]
} |
@jfecher what is the status of this issue? |
@kevaundray there is a workaround for it now, and the original issue is a duplicate of the bug reported in #562, so I'm closing this one. |
Description
Aim
Expected behavior
itDoesnt
should work without going throughid
.Bug
To reproduce
nargo build
Environment
(Specify your setup and versions of dependencies.)
The text was updated successfully, but these errors were encountered: