-
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.
- Loading branch information
Showing
4 changed files
with
37 additions
and
1 deletion.
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/regression_6077/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_6077" | ||
type = "bin" | ||
authors = [""] | ||
compiler_version = ">=0.30.0" | ||
|
||
[dependencies] |
1 change: 1 addition & 0 deletions
1
test_programs/compile_success_empty/regression_6077/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 @@ | ||
a = 0 |
28 changes: 28 additions & 0 deletions
28
test_programs/compile_success_empty/regression_6077/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,28 @@ | ||
struct WeirdStruct<T, U> { | ||
a: T, | ||
b: U, | ||
} | ||
|
||
#[mangle_fn] | ||
pub fn my_fn() -> [u8; 3] { | ||
[0; 3] | ||
} | ||
|
||
comptime fn mangle_fn(f: FunctionDefinition) { | ||
let return_type = f.return_type(); | ||
|
||
// This relies on how types are displayed | ||
let generics = f"Field,{return_type}".quoted_contents(); | ||
let new_return_type = quote { WeirdStruct<$generics>}.as_type(); | ||
|
||
let new_body = quote { | ||
{ | ||
WeirdStruct { a: 1, b: [0;3] } | ||
} | ||
}.as_expr().unwrap(); | ||
|
||
f.set_return_type(new_return_type); | ||
f.set_body(new_body); | ||
} | ||
|
||
fn main() {} |