-
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.
# Description ## Problem\* Resolves #4639 ## Summary\* The array to slice coercion was broken - and it seemingly has always been so. The coercion never actually called `replace_expr` to replace the original expression with the `as_slice(original_expr)` coercion. ## 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
Showing
4 changed files
with
38 additions
and
5 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
[package] | ||
name = "slice_coercion" | ||
type = "bin" | ||
authors = [""] | ||
compiler_version = ">=0.25.0" | ||
|
||
[dependencies] |
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,2 @@ | ||
first = 3 | ||
expected = 3 |
19 changes: 19 additions & 0 deletions
19
test_programs/execution_success/slice_coercion/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,19 @@ | ||
struct Hasher { | ||
fields: [Field], | ||
} | ||
|
||
impl Hasher { | ||
pub fn new() -> Self { | ||
Self { fields: [] } | ||
} | ||
|
||
pub fn add(&mut self, field: Field) { | ||
self.fields = self.fields.push_back(field); | ||
} | ||
} | ||
|
||
fn main(expected: pub Field, first: Field) { | ||
let mut hasher = Hasher::new(); | ||
hasher.add(first); | ||
assert(hasher.fields[0] == expected); | ||
} |