Skip to content

Commit

Permalink
feat: Set aztec private functions to be recursive (AztecProtocol#6192)
Browse files Browse the repository at this point in the history
This PR marks aztec private functions as recursive.
  • Loading branch information
PhilWindle authored May 3, 2024
1 parent 3abc862 commit 22625f8
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions noir/noir-repo/aztec_macros/src/transforms/functions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ use noirc_errors::Span;
use noirc_frontend::ast;
use noirc_frontend::ast::{
BlockExpression, ConstrainKind, ConstrainStatement, Expression, ExpressionKind,
ForLoopStatement, ForRange, FunctionReturnType, Ident, Literal, NoirFunction, NoirStruct,
Param, PathKind, Pattern, Signedness, Statement, StatementKind, UnresolvedType,
ForLoopStatement, ForRange, FunctionKind, FunctionReturnType, Ident, Literal, NoirFunction,
NoirStruct, Param, PathKind, Pattern, Signedness, Statement, StatementKind, UnresolvedType,
UnresolvedTypeData, Visibility,
};

Expand Down Expand Up @@ -38,6 +38,7 @@ pub fn transform_function(
let inputs_name = format!("{}ContextInputs", ty);
let return_type_name = format!("{}CircuitPublicInputs", ty);
let is_avm = ty == "Avm";
let is_private = ty == "Private";

// Add check that msg sender equals this address and flag function as internal
if is_internal {
Expand Down Expand Up @@ -107,6 +108,11 @@ pub fn transform_function(
// Public functions should have unconstrained auto-inferred
func.def.is_unconstrained = matches!(ty, "Public" | "Avm");

// Private functions need to be recursive
if is_private {
func.kind = FunctionKind::Recursive;
}

Ok(())
}

Expand Down

0 comments on commit 22625f8

Please sign in to comment.