Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Fix comptime type formatting #6079

Merged
merged 2 commits into from
Sep 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion compiler/noirc_frontend/src/hir/comptime/value.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,8 @@
Value::Expr(ExprValue::Statement(statement))
}

pub(crate) fn lvalue(lvaue: LValue) -> Self {

Check warning on line 104 in compiler/noirc_frontend/src/hir/comptime/value.rs

View workflow job for this annotation

GitHub Actions / Code

Unknown word (lvaue)
Value::Expr(ExprValue::LValue(lvaue))

Check warning on line 105 in compiler/noirc_frontend/src/hir/comptime/value.rs

View workflow job for this annotation

GitHub Actions / Code

Unknown word (lvaue)
}

pub(crate) fn pattern(pattern: Pattern) -> Self {
Expand Down Expand Up @@ -682,7 +682,7 @@
}
}
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()))
}
Expand Down
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]
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
a = 0
28 changes: 28 additions & 0 deletions test_programs/compile_success_empty/regression_6077/src/main.nr
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() {}
Loading