-
Notifications
You must be signed in to change notification settings - Fork 225
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: don't always select trait impl when verifying trait constraints (#…
- Loading branch information
Showing
13 changed files
with
210 additions
and
9 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
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_empty/regression_7038/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 = "regression_7038" | ||
type = "bin" | ||
authors = [""] | ||
compiler_version = ">=0.30.0" | ||
|
||
[dependencies] |
40 changes: 40 additions & 0 deletions
40
test_programs/compile_success_empty/regression_7038/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,40 @@ | ||
trait BigNumTrait {} | ||
|
||
pub struct MyBigNum; | ||
|
||
impl crate::BigNumTrait for MyBigNum {} | ||
|
||
trait CurveParamsTrait<BigNum> | ||
where | ||
BigNum: BigNumTrait, | ||
{ | ||
fn one(); | ||
} | ||
|
||
pub struct BN254Params; | ||
impl CurveParamsTrait<MyBigNum> for BN254Params { | ||
|
||
fn one() {} | ||
} | ||
|
||
trait BigCurveTrait { | ||
fn two(); | ||
} | ||
|
||
pub struct BigCurve<BigNum, CurveParams> {} | ||
|
||
type BN254 = BigCurve<MyBigNum, BN254Params>; | ||
|
||
impl<BigNum, CurveParams> BigCurveTrait for BigCurve<BigNum, CurveParams> | ||
where | ||
BigNum: BigNumTrait, | ||
CurveParams: CurveParamsTrait<BigNum>, | ||
{ | ||
fn two() { | ||
let _ = CurveParams::one(); | ||
} | ||
} | ||
|
||
fn main() { | ||
let _ = BN254::two(); | ||
} |
7 changes: 7 additions & 0 deletions
7
test_programs/compile_success_empty/regression_7038_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 = "regression_7038_2" | ||
type = "bin" | ||
authors = [""] | ||
compiler_version = ">=0.30.0" | ||
|
||
[dependencies] |
39 changes: 39 additions & 0 deletions
39
test_programs/compile_success_empty/regression_7038_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,39 @@ | ||
trait BigNumTrait {} | ||
|
||
pub struct MyBigNum; | ||
|
||
impl crate::BigNumTrait for MyBigNum {} | ||
|
||
trait CurveParamsTrait<BigNum> | ||
where | ||
BigNum: BigNumTrait, | ||
{ | ||
// The difference between this and regression_7083 is that here | ||
// this is a default method. | ||
fn one() {} | ||
} | ||
|
||
pub struct BN254Params; | ||
impl CurveParamsTrait<MyBigNum> for BN254Params {} | ||
|
||
trait BigCurveTrait { | ||
fn two(); | ||
} | ||
|
||
pub struct BigCurve<BigNum, CurveParams> {} | ||
|
||
type BN254 = BigCurve<MyBigNum, BN254Params>; | ||
|
||
impl<BigNum, CurveParams> BigCurveTrait for BigCurve<BigNum, CurveParams> | ||
where | ||
BigNum: BigNumTrait, | ||
CurveParams: CurveParamsTrait<BigNum>, | ||
{ | ||
fn two() { | ||
let _ = CurveParams::one(); | ||
} | ||
} | ||
|
||
fn main() { | ||
let _ = BN254::two(); | ||
} |
7 changes: 7 additions & 0 deletions
7
test_programs/compile_success_empty/regression_7038_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 = "regression_7038_3" | ||
type = "bin" | ||
authors = [""] | ||
compiler_version = ">=0.30.0" | ||
|
||
[dependencies] |
40 changes: 40 additions & 0 deletions
40
test_programs/compile_success_empty/regression_7038_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,40 @@ | ||
trait BigNumTrait {} | ||
|
||
pub struct MyBigNum; | ||
|
||
impl crate::BigNumTrait for MyBigNum {} | ||
|
||
trait CurveParamsTrait<BigNum> { | ||
// The difference between this and regression_7038 and regression_7038_2 is that | ||
// here the where clause is on the method, not the trait | ||
fn one() | ||
where | ||
BigNum: BigNumTrait; | ||
} | ||
|
||
pub struct BN254Params; | ||
impl CurveParamsTrait<MyBigNum> for BN254Params { | ||
fn one() {} | ||
} | ||
|
||
trait BigCurveTrait { | ||
fn two(); | ||
} | ||
|
||
pub struct BigCurve<BigNum, CurveParams> {} | ||
|
||
type BN254 = BigCurve<MyBigNum, BN254Params>; | ||
|
||
impl<BigNum, CurveParams> BigCurveTrait for BigCurve<BigNum, CurveParams> | ||
where | ||
BigNum: BigNumTrait, | ||
CurveParams: CurveParamsTrait<BigNum>, | ||
{ | ||
fn two() { | ||
let _ = CurveParams::one(); | ||
} | ||
} | ||
|
||
fn main() { | ||
let _ = BN254::two(); | ||
} |
7 changes: 7 additions & 0 deletions
7
test_programs/compile_success_empty/regression_7038_4/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 = "regression_7038_4" | ||
type = "bin" | ||
authors = [""] | ||
compiler_version = ">=0.30.0" | ||
|
||
[dependencies] |
29 changes: 29 additions & 0 deletions
29
test_programs/compile_success_empty/regression_7038_4/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,29 @@ | ||
// This program is a reduction of regression_7038_3 that led to a monomorphizer crash | ||
trait BigNumTrait {} | ||
|
||
trait CurveParamsTrait<BigNum> { | ||
fn one() | ||
where | ||
BigNum: BigNumTrait; | ||
} | ||
|
||
pub struct MyBigNum; | ||
|
||
impl BigNumTrait for MyBigNum {} | ||
|
||
pub struct Params; | ||
impl CurveParamsTrait<MyBigNum> for Params { | ||
|
||
fn one() {} | ||
} | ||
|
||
fn foo<C>() | ||
where | ||
C: CurveParamsTrait<MyBigNum>, | ||
{ | ||
let _ = C::one(); | ||
} | ||
|
||
fn main() { | ||
foo::<Params>(); | ||
} |