You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Attempted to pass a mutable enum to an unconstrained function that accepts an immutable instance of the type
pubenumFoo {
Bar,
}
pubunconstrainedfnbaz(_x: Field) { }
pubunconstrainedfnqux(_x: Foo) { }
fnmain() {
letmut x: Field = 0;
letmut y: Foo = Foo::Bar;
// Safety: this passesunsafe {
baz(x);
}
// Safety: this has a "mutable reference" errorunsafe {
qux(y);
}
}
Expected Behavior
Expected the mutable reference to be dereferenced when being passed to fn qux(_x: Foo).
Bug
Compilation fails for the enum case:
❯ clr;~/.nargo/bin/nargo compile -Zenums
error: Cannot pass a mutable reference from a constrained runtime to an unconstrained runtime
┌─ src/main.nr:19:13
│
19 │ qux(y);
│ -
│
Aborting due to 1 previous error
It appears that mutable references to enums aren't being handled correctly. E.g. I expected that I might be able to make an explicitly non-mutable copy of y, i.e.
letz: Foo = y;
qux(z);
But it fails with the same error.
To Reproduce
Workaround
Yes
Workaround Description
Using an unconstrained main function
Additional Context
No response
Project Impact
Nice-to-have
Blocker Context
No response
Nargo Version
nargo version = 1.0.0-beta.3 noirc version = 1.0.0-beta.3+37be49fd081f33dc7256d23cee8ccc0719c50a82 (git version hash: 37be49f, is dirty: false)
NoirJS Version
No response
Proving Backend Tooling & 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:
This isn't a duplicate of #7558 because it fails with the Cannot pass a mutable reference from a constrained runtime to an unconstrained runtime error when Foo isn't a mutable reference:
Aim
Attempted to pass a mutable enum to an unconstrained function that accepts an immutable instance of the type
Expected Behavior
Expected the mutable reference to be dereferenced when being passed to
fn qux(_x: Foo)
.Bug
Compilation fails for the enum case:
It appears that mutable references to enums aren't being handled correctly. E.g. I expected that I might be able to make an explicitly non-mutable copy of
y
, i.e.But it fails with the same error.
To Reproduce
Workaround
Yes
Workaround Description
Using an unconstrained
main
functionAdditional Context
No response
Project Impact
Nice-to-have
Blocker Context
No response
Nargo Version
nargo version = 1.0.0-beta.3 noirc version = 1.0.0-beta.3+37be49fd081f33dc7256d23cee8ccc0719c50a82 (git version hash: 37be49f, is dirty: false)
NoirJS Version
No response
Proving Backend Tooling & 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: