From 856941a898253471f7b312d4174534c7cbd5a809 Mon Sep 17 00:00:00 2001 From: Jake Fecher Date: Wed, 18 Sep 2024 08:36:43 -0500 Subject: [PATCH 1/2] Fix type formatting --- compiler/noirc_frontend/src/hir/comptime/value.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/compiler/noirc_frontend/src/hir/comptime/value.rs b/compiler/noirc_frontend/src/hir/comptime/value.rs index f2cb714deb4..b027d069536 100644 --- a/compiler/noirc_frontend/src/hir/comptime/value.rs +++ b/compiler/noirc_frontend/src/hir/comptime/value.rs @@ -682,7 +682,7 @@ impl<'value, 'interner> Display for ValuePrinter<'value, 'interner> { } } Value::Zeroed(typ) => write!(f, "(zeroed {typ})"), - Value::Type(typ) => write!(f, "{:?}", typ), + Value::Type(typ) => write!(f, "{}", typ), Value::Expr(ExprValue::Expression(expr)) => { write!(f, "{}", remove_interned_in_expression_kind(self.interner, expr.clone())) } From 79d5387cfd1bddd1094bf2b8ebbd33f5aef9f03b Mon Sep 17 00:00:00 2001 From: Jake Fecher Date: Wed, 18 Sep 2024 08:39:58 -0500 Subject: [PATCH 2/2] Add test --- .../regression_6077/Nargo.toml | 7 +++++ .../regression_6077/Prover.toml | 1 + .../regression_6077/src/main.nr | 28 +++++++++++++++++++ 3 files changed, 36 insertions(+) create mode 100644 test_programs/compile_success_empty/regression_6077/Nargo.toml create mode 100644 test_programs/compile_success_empty/regression_6077/Prover.toml create mode 100644 test_programs/compile_success_empty/regression_6077/src/main.nr diff --git a/test_programs/compile_success_empty/regression_6077/Nargo.toml b/test_programs/compile_success_empty/regression_6077/Nargo.toml new file mode 100644 index 00000000000..0c1118245f4 --- /dev/null +++ b/test_programs/compile_success_empty/regression_6077/Nargo.toml @@ -0,0 +1,7 @@ +[package] +name = "regression_6077" +type = "bin" +authors = [""] +compiler_version = ">=0.30.0" + +[dependencies] diff --git a/test_programs/compile_success_empty/regression_6077/Prover.toml b/test_programs/compile_success_empty/regression_6077/Prover.toml new file mode 100644 index 00000000000..ba3522cab01 --- /dev/null +++ b/test_programs/compile_success_empty/regression_6077/Prover.toml @@ -0,0 +1 @@ +a = 0 diff --git a/test_programs/compile_success_empty/regression_6077/src/main.nr b/test_programs/compile_success_empty/regression_6077/src/main.nr new file mode 100644 index 00000000000..fe067177e77 --- /dev/null +++ b/test_programs/compile_success_empty/regression_6077/src/main.nr @@ -0,0 +1,28 @@ +struct WeirdStruct { + 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() {}