-
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: disambiguate field or int static trait method call (#6112)
# Description ## Problem Resolves #6106 ## Summary ## Additional Context Let me know if this isn't the correct way to solve this. ## 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
72 additions
and
17 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/compile_success_empty/field_or_integer_static_trait_method/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 = "field_or_int_static_trait_method" | ||
type = "bin" | ||
authors = [""] | ||
compiler_version = ">=0.32.0" | ||
|
||
[dependencies] |
25 changes: 25 additions & 0 deletions
25
test_programs/compile_success_empty/field_or_integer_static_trait_method/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,25 @@ | ||
trait Read { | ||
fn read(data: [Field; 1]) -> Self; | ||
} | ||
|
||
impl Read for Field { | ||
fn read(data: [Field; 1]) -> Self { | ||
data[0] * 10 | ||
} | ||
} | ||
|
||
impl Read for u32 { | ||
fn read(data: [Field; 1]) -> Self { | ||
data[0] as u32 | ||
} | ||
} | ||
|
||
fn main() { | ||
let data = [1]; | ||
|
||
let value: u32 = u32::read(data); | ||
assert_eq(value, 1); | ||
|
||
let value: Field = Field::read(data); | ||
assert_eq(value, 10); | ||
} |
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