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

chore: remove original return from aztec fns #4804

Merged
merged 7 commits into from
Feb 28, 2024
Merged
Changes from 1 commit
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
8 changes: 6 additions & 2 deletions noir/aztec_macros/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1253,7 +1253,7 @@ fn create_avm_context() -> Result<Statement, AztecMacroError> {
/// Similarly; Structs will be pushed to the context, after serialize() is called on them.
/// Arrays will be iterated over and each element will be pushed to the context.
/// Any primitive type that can be cast will be casted to a field and pushed to the context.
fn abstract_return_values(func: &NoirFunction) -> Option<Statement> {
fn abstract_return_values(func: &mut NoirFunction) -> Option<Statement> {
let current_return_type = func.return_type().typ;
let len = func.def.body.len();
let last_statement = &func.def.body.0[len - 1];
Expand All @@ -1265,7 +1265,7 @@ fn abstract_return_values(func: &NoirFunction) -> Option<Statement> {
// Check if the return type is an expression, if it is, we can handle it
match last_statement {
Statement { kind: StatementKind::Expression(expression), .. } => {
match current_return_type {
let new_return = match current_return_type {
// Call serialize on structs, push the whole array, calling push_array
UnresolvedTypeData::Named(..) => Some(make_struct_return_type(expression.clone())),
UnresolvedTypeData::Array(..) => Some(make_array_return_type(expression.clone())),
Expand All @@ -1275,7 +1275,11 @@ fn abstract_return_values(func: &NoirFunction) -> Option<Statement> {
}
UnresolvedTypeData::FieldElement => Some(make_return_push(expression.clone())),
_ => None,
};
if new_return.is_some() {
func.def_mut().body.0.remove(len - 1);
Thunkar marked this conversation as resolved.
Show resolved Hide resolved
}
new_return
}
_ => None,
}
Expand Down
Loading