-
Notifications
You must be signed in to change notification settings - Fork 219
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: replace
regression_5202
with more manageably sized program (#…
…5345) # Description ## Problem\* Resolves <!-- Link to GitHub Issue --> ## Summary\* This PR replaces `regression_5202` with another program which expresses the same issue but is much smaller and so easier to debug if we get a regression in future. Thanks to @nventuro for contributing this minimal reproduction. ## Additional Context ## 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 <jake@aztecprotocol.com>
- Loading branch information
1 parent
554dd6b
commit fcacb60
Showing
7 changed files
with
42 additions
and
263 deletions.
There are no files selected for viewing
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
41 changes: 41 additions & 0 deletions
41
test_programs/execution_failure/regression_5202/src/main.nr
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
trait ToField { | ||
fn to_field(self) -> Field; | ||
} | ||
|
||
impl ToField for bool { fn to_field(self) -> Field { self as Field } } | ||
|
||
unconstrained fn get_unconstrained_option() -> Option<u32> { | ||
Option::some(13) | ||
} | ||
|
||
unconstrained fn should_i_assert() -> bool { | ||
false | ||
} | ||
|
||
fn get_magical_boolean() -> bool { | ||
let option = get_unconstrained_option(); | ||
|
||
let pre_assert = option.is_some().to_field(); | ||
|
||
if should_i_assert() { | ||
// Note that `should_i_assert` is unconstrained, so Noir should not be able to infer | ||
// any behavior from the contents of this block. In this case it is actually false, so the | ||
// assertion below is not even executed (if it did it'd fail since the values are not equal). | ||
|
||
assert_eq(option, Option::some(42)); /// <- this seems to be the trigger for the bug | ||
} | ||
|
||
// In my testing, the `option` value exhibits weird behavior from this point on, as if it had been mutated | ||
let post_assert = option.is_some().to_field(); | ||
|
||
// The following expression should be true, but I can get it to evaluate to false depending on how I call it | ||
pre_assert == post_assert | ||
} | ||
|
||
fn main() { | ||
let magic = get_magical_boolean(); | ||
|
||
// One of these asserts should fail. Before #5202, they would both pass | ||
assert_eq(magic, true); | ||
assert_eq(magic, false); | ||
} |
21 changes: 0 additions & 21 deletions
21
test_programs/execution_success/regression_5202/fraction/LICENSE
This file was deleted.
Oops, something went wrong.
6 changes: 0 additions & 6 deletions
6
test_programs/execution_success/regression_5202/fraction/Nargo.toml
This file was deleted.
Oops, something went wrong.
10 changes: 0 additions & 10 deletions
10
test_programs/execution_success/regression_5202/fraction/README.md
This file was deleted.
Oops, something went wrong.
201 changes: 0 additions & 201 deletions
201
test_programs/execution_success/regression_5202/fraction/src/lib.nr
This file was deleted.
Oops, something went wrong.
23 changes: 0 additions & 23 deletions
23
test_programs/execution_success/regression_5202/src/main.nr
This file was deleted.
Oops, something went wrong.