-
Notifications
You must be signed in to change notification settings - Fork 230
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: enforce correctness of decompositions performed at compile time (#…
…6278) # Description ## Problem\* Resolves #6244 ## Summary\* We were not checking that a radix decomposition simplification performed at compile time was valid, resulting in a truncation to fit the result array. This PR prevents the simplification in this case so we can instead error at runtime. ## 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.
- Loading branch information
1 parent
67ac0d6
commit 53252fd
Showing
5 changed files
with
40 additions
and
15 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
7 changes: 7 additions & 0 deletions
7
test_programs/execution_failure/invalid_comptime_bits_decomposition/Nargo.toml
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 = "invalid_comptime_bits_decomposition" | ||
type = "bin" | ||
authors = [""] | ||
compiler_version = ">=0.30.0" | ||
|
||
[dependencies] |
5 changes: 5 additions & 0 deletions
5
test_programs/execution_failure/invalid_comptime_bits_decomposition/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,5 @@ | ||
fn main() -> pub [u1; 1] { | ||
let large_number: Field = 2; | ||
|
||
large_number.to_be_bits() | ||
} |
7 changes: 7 additions & 0 deletions
7
test_programs/execution_failure/invalid_comptime_bytes_decomposition/Nargo.toml
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 = "invalid_comptime_bytes_decomposition" | ||
type = "bin" | ||
authors = [""] | ||
compiler_version = ">=0.30.0" | ||
|
||
[dependencies] |
4 changes: 4 additions & 0 deletions
4
test_programs/execution_failure/invalid_comptime_bytes_decomposition/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,4 @@ | ||
fn main() -> pub [u8; 1] { | ||
let large_number: Field = 256; | ||
large_number.to_be_bytes() | ||
} |