-
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(elaborator): Fix duplicate methods error (#5225)
# Description ## Problem\* Resolves "duplicate method" error when declaring trait methods on different traits with the same method name in the elaborator. ## Summary\* ## Additional Context This was the last error type in aztec packages for the elaborator. ~~After this, there are still some extra unused variable warnings I will fix but the entire crate tests successfully.~~ Nevermind, looks like aztec-nr just naturally has many unused variables ## 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
5 changed files
with
64 additions
and
16 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
6 changes: 6 additions & 0 deletions
6
test_programs/compile_success_empty/no_duplicate_methods/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,6 @@ | ||
[package] | ||
name = "no_duplicate_methods" | ||
type = "bin" | ||
authors = [""] | ||
|
||
[dependencies] |
Empty file.
26 changes: 26 additions & 0 deletions
26
test_programs/compile_success_empty/no_duplicate_methods/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,26 @@ | ||
// Test that declaring several methods & trait methods with the same name | ||
// does not trigger a duplicate method error | ||
trait ToField { | ||
fn to_field(self) -> Field; | ||
} | ||
trait ToField2 { | ||
fn to_field(self) -> Field; | ||
} | ||
|
||
struct Foo { x: Field } | ||
|
||
impl ToField for Foo { | ||
fn to_field(self) -> Field { self.x } | ||
} | ||
|
||
impl ToField2 for Foo { | ||
fn to_field(self) -> Field { self.x } | ||
} | ||
|
||
impl Foo { | ||
fn to_field(self) -> Field { | ||
self.x | ||
} | ||
} | ||
|
||
fn main() {} |