-
Notifications
You must be signed in to change notification settings - Fork 212
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: optimizer to keep track of changing opcode locations (#6781)
- Loading branch information
Showing
6 changed files
with
79 additions
and
23 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
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
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,7 @@ | ||
[package] | ||
name = "assert_message" | ||
type = "bin" | ||
authors = [""] | ||
compiler_version = ">=0.23.0" | ||
|
||
[dependencies] |
15 changes: 15 additions & 0 deletions
15
test_programs/noir_test_success/assert_message/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,15 @@ | ||
// Have to use inputs otherwise the ACIR gets optimized away due to constants. | ||
// With the original ACIR the optimizations can rearrange or merge opcodes, | ||
// which might end up getting out of sync with assertion messages. | ||
#[test(should_fail_with = "first")] | ||
fn test_assert_message_preserved_during_optimization(a: Field, b: Field, c: Field) { | ||
if (a + b) * (a - b) != c { | ||
assert((a + b) * (a - b) == c, "first"); | ||
assert((a - b) * (a + b) == c, "second"); | ||
assert((a + b) * (a - b) == c, "third"); | ||
assert((2 * a + b) * (a - b / 2) == c * c, "fourth"); | ||
} else { | ||
// The fuzzer might have generated a passing test. | ||
assert((a + b) * (a - b) != c, "first"); | ||
} | ||
} |
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 |
---|---|---|
@@ -1,6 +1,9 @@ | ||
|
||
#[test(should_fail_with = "42 is not allowed")] | ||
fn finds_magic_value(x: u32) { | ||
let x = x as u64; | ||
assert(2 * x != 42, "42 is not allowed"); | ||
if x == 21 { | ||
assert(2 * x != 42, "42 is not allowed"); | ||
} else { | ||
assert(2 * x == 42, "42 is not allowed"); | ||
} | ||
} |
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