-
Notifications
You must be signed in to change notification settings - Fork 204
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(traits): Add default and override of methods (#2585)
Co-authored-by: Yordan Madzhunkov <[email protected]>
- Loading branch information
1 parent
6110638
commit 98c3ba9
Showing
17 changed files
with
257 additions
and
131 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,6 +25,4 @@ impl Default for Foo { | |
|
||
|
||
fn main(x: Field, y: Field) { | ||
let first = Foo::default(x,y); | ||
assert(first.bar == x); | ||
} |
7 changes: 7 additions & 0 deletions
7
crates/nargo_cli/tests/compile_failure/dup_trait_implementation_2/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 = "dup_trait_implementation_2" | ||
type = "bin" | ||
authors = [""] | ||
compiler_version = "0.9.0" | ||
|
||
[dependencies] |
2 changes: 2 additions & 0 deletions
2
crates/nargo_cli/tests/compile_failure/dup_trait_implementation_2/Prover.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,2 @@ | ||
x = 1 | ||
y = 2 |
18 changes: 18 additions & 0 deletions
18
crates/nargo_cli/tests/compile_failure/dup_trait_implementation_2/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,18 @@ | ||
trait Default { | ||
} | ||
|
||
struct Foo { | ||
bar: Field, | ||
} | ||
|
||
// Duplicate trait implementations should not compile | ||
impl Default for Foo { | ||
} | ||
|
||
// Duplicate trait implementations should not compile | ||
impl Default for Foo { | ||
} | ||
|
||
|
||
fn main(x: Field, y: Field) { | ||
} |
7 changes: 7 additions & 0 deletions
7
crates/nargo_cli/tests/compile_failure/dup_trait_implementation_3/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 = "dup_trait_implementation_3" | ||
type = "bin" | ||
authors = [""] | ||
compiler_version = "0.9.0" | ||
|
||
[dependencies] |
2 changes: 2 additions & 0 deletions
2
crates/nargo_cli/tests/compile_failure/dup_trait_implementation_3/Prover.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,2 @@ | ||
x = 1 | ||
y = 2 |
19 changes: 19 additions & 0 deletions
19
crates/nargo_cli/tests/compile_failure/dup_trait_implementation_3/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 @@ | ||
trait Default { | ||
} | ||
|
||
struct MyStruct { | ||
} | ||
|
||
type MyType = MyStruct; | ||
|
||
// Duplicate trait implementations should not compile | ||
impl Default for MyStruct { | ||
} | ||
|
||
// Duplicate trait implementations should not compile | ||
impl Default for MyType { | ||
} | ||
|
||
|
||
fn main(x: Field, y: Field) { | ||
} |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
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
Oops, something went wrong.