-
Notifications
You must be signed in to change notification settings - Fork 200
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Update databus in flattening (#6063)
# Description ## Problem\* Resolves #5705 ## Summary\* We were using an inserter in flattening but forgot to update the databus ## 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\* - [ ] I have tested the changes locally. - [ ] I have formatted the changes with [Prettier](https://prettier.io/) and/or `cargo fmt` on default settings.
- Loading branch information
1 parent
052c4fe
commit e993da1
Showing
5 changed files
with
59 additions
and
2 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
7 changes: 7 additions & 0 deletions
7
test_programs/compile_success_no_bug/databus_mapping_regression/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 = "databus_mapping_regression" | ||
type = "bin" | ||
authors = [""] | ||
compiler_version = ">=0.31.0" | ||
|
||
[dependencies] |
42 changes: 42 additions & 0 deletions
42
test_programs/compile_success_no_bug/databus_mapping_regression/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,42 @@ | ||
trait Empty { | ||
fn empty() -> Self; | ||
} | ||
|
||
impl Empty for Field { | ||
fn empty() -> Self { | ||
0 | ||
} | ||
} | ||
|
||
pub fn is_empty<T>(item: T) -> bool where T: Empty + Eq { | ||
item.eq(T::empty()) | ||
} | ||
|
||
pub fn array_to_bounded_vec<T, let N: u32>(array: [T; N]) -> BoundedVec<T, N> where T: Empty + Eq { | ||
let mut len = 0; | ||
for elem in array { | ||
if !is_empty(elem) { | ||
len += 1; | ||
} | ||
} | ||
|
||
BoundedVec { storage: array, len } | ||
} | ||
|
||
global TX_SIZE = 5; | ||
global APP_CALL_SIZE = 2; | ||
|
||
fn main( | ||
a: call_data(0) [Field; TX_SIZE], | ||
b: call_data(1) [Field; APP_CALL_SIZE] | ||
) -> return_data [Field; TX_SIZE] { | ||
let mut a_as_bounded_vec = array_to_bounded_vec(a); | ||
|
||
for i in 0..APP_CALL_SIZE { | ||
let value = b[i]; | ||
if value != 0 { | ||
a_as_bounded_vec.push(value); | ||
} | ||
} | ||
a_as_bounded_vec.storage | ||
} |