Skip to content

Commit

Permalink
chore: replace regression_5202 with more manageably sized program (#…
Browse files Browse the repository at this point in the history
…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
TomAFrench and jfecher authored Jun 27, 2024
1 parent 554dd6b commit fcacb60
Show file tree
Hide file tree
Showing 7 changed files with 42 additions and 263 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
name = "regression_5202"
type = "bin"
authors = [""]
compiler_version = ">=0.30.0"
compiler_version = ">=0.29.0"

[dependencies]
fraction = { path = "fraction" }
41 changes: 41 additions & 0 deletions test_programs/execution_failure/regression_5202/src/main.nr
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 test_programs/execution_success/regression_5202/fraction/LICENSE

This file was deleted.

This file was deleted.

10 changes: 0 additions & 10 deletions test_programs/execution_success/regression_5202/fraction/README.md

This file was deleted.

201 changes: 0 additions & 201 deletions test_programs/execution_success/regression_5202/fraction/src/lib.nr

This file was deleted.

23 changes: 0 additions & 23 deletions test_programs/execution_success/regression_5202/src/main.nr

This file was deleted.

0 comments on commit fcacb60

Please sign in to comment.