Skip to content

Commit

Permalink
feat: Sync from aztec-packages (#4444)
Browse files Browse the repository at this point in the history
BEGIN_COMMIT_OVERRIDE
chore: remove original return from aztec fns
(AztecProtocol/aztec-packages#4804)
END_COMMIT_OVERRIDE

---------

Co-authored-by: TomAFrench <[email protected]>
  • Loading branch information
AztecBot and TomAFrench authored Feb 28, 2024
1 parent 9544813 commit 9c20538
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
2 changes: 1 addition & 1 deletion .aztec-sync-commit
Original file line number Diff line number Diff line change
@@ -1 +1 @@
e69b58660ff843350e1e098d8f1a84f4ce3d3c34
9e246c1289fa40c35c4b28d2f0081dfdc2aa9d19
8 changes: 5 additions & 3 deletions aztec_macros/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -648,6 +648,10 @@ fn transform_function(

// Abstract return types such that they get added to the kernel's return_values
if let Some(return_values) = abstract_return_values(func) {
// In case we are pushing return values to the context, we remove the statement that originated it
// This avoids running duplicate code, since blocks like if/else can be value returning statements
func.def.body.0.pop();
// Add the new return statement
func.def.body.0.push(return_values);
}

Expand Down Expand Up @@ -1255,13 +1259,11 @@ fn create_avm_context() -> Result<Statement, AztecMacroError> {
/// 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> {
let current_return_type = func.return_type().typ;
let len = func.def.body.len();
let last_statement = &func.def.body.0[len - 1];
let last_statement = func.def.body.0.last()?;

// TODO: (length, type) => We can limit the size of the array returned to be limited by kernel size
// Doesn't need done until we have settled on a kernel size
// TODO: support tuples here and in inputs -> convert into an issue

// Check if the return type is an expression, if it is, we can handle it
match last_statement {
Statement { kind: StatementKind::Expression(expression), .. } => {
Expand Down

0 comments on commit 9c20538

Please sign in to comment.