diff --git a/compiler/noirc_evaluator/src/ssa/opt/defunctionalize.rs b/compiler/noirc_evaluator/src/ssa/opt/defunctionalize.rs index 0f2c2a14abf..a1e50d77acb 100644 --- a/compiler/noirc_evaluator/src/ssa/opt/defunctionalize.rs +++ b/compiler/noirc_evaluator/src/ssa/opt/defunctionalize.rs @@ -181,7 +181,11 @@ impl DefunctionalizationContext { }; // Find the correct apply function - let apply_function = self.get_apply_function(signature, func.runtime()); + let Some(apply_function) = + self.get_apply_function(signature, func.runtime()) + else { + continue; + }; // Replace the instruction with a call to apply let apply_function_value_id = func.dfg.import_function(apply_function.id); @@ -201,8 +205,12 @@ impl DefunctionalizationContext { } /// Returns the apply function for the given signature - fn get_apply_function(&self, signature: Signature, runtime: RuntimeType) -> ApplyFunction { - *self.apply_functions.get(&(signature, runtime)).expect("Could not find apply function") + fn get_apply_function( + &self, + signature: Signature, + runtime: RuntimeType, + ) -> Option { + self.apply_functions.get(&(signature, runtime)).copied() } } @@ -376,10 +384,10 @@ fn find_dynamic_dispatches(func: &Function) -> BTreeSet { fn create_apply_functions(ssa: &mut Ssa, variants_map: Variants) -> ApplyFunctions { let mut apply_functions = HashMap::default(); for ((mut signature, runtime), variants) in variants_map.into_iter() { - assert!( - !variants.is_empty(), - "ICE: at least one variant should exist for a dynamic call {signature:?}" - ); + if variants.is_empty() { + // If no variants exist for a dynamic call we leave removing those dead parameters to DIE + continue; + } let dispatches_to_multiple_functions = variants.len() > 1; // Update the shared function signature of the higher-order function variants @@ -804,4 +812,47 @@ mod tests { " ); } + + #[test] + fn missing_fn_variant() { + let src = " + brillig(inline) fn main f0 { + b0(): + v2 = call f1(f2) -> i64 + return v2 + } + brillig(inline) fn func_3 f1 { + b0(v0: function): + return i64 0 + } + brillig(inline) fn func_2 f2 { + b0(v0: function): + v2 = call v0(u128 1) -> u1 + return v2 + } + "; + + let ssa = Ssa::from_str(src).unwrap(); + let ssa = ssa.defunctionalize(); + + // We still expect all parameters with a function type to be replaced. + // However, this is fine as a function with no variants means that function + // was never actually called. + assert_ssa_snapshot!(ssa, @r" + brillig(inline) fn main f0 { + b0(): + v2 = call f1(Field 2) -> i64 + return v2 + } + brillig(inline) fn func_3 f1 { + b0(v0: Field): + return i64 0 + } + brillig(inline) fn func_2 f2 { + b0(v0: Field): + v2 = call v0(u128 1) -> u1 + return v2 + } + "); + } } diff --git a/test_programs/execution_success/lambda_taking_lambda_regression_8543/Nargo.toml b/test_programs/execution_success/lambda_taking_lambda_regression_8543/Nargo.toml new file mode 100644 index 00000000000..a1f4699b3c2 --- /dev/null +++ b/test_programs/execution_success/lambda_taking_lambda_regression_8543/Nargo.toml @@ -0,0 +1,6 @@ +[package] +name = "lambda_taking_lambda_regression_8543" +type = "bin" +authors = [""] + +[dependencies] \ No newline at end of file diff --git a/test_programs/execution_success/lambda_taking_lambda_regression_8543/src/main.nr b/test_programs/execution_success/lambda_taking_lambda_regression_8543/src/main.nr new file mode 100644 index 00000000000..a1dd94d1a9c --- /dev/null +++ b/test_programs/execution_success/lambda_taking_lambda_regression_8543/src/main.nr @@ -0,0 +1,11 @@ +// Regression for issue #8543 (https://github.com/noir-lang/noir/issues/8543) +unconstrained fn main() -> pub i64 { + func_3(func_2) +} + +unconstrained fn func_2(a: unconstrained fn(u128) -> bool) -> bool { + a(1) +} +unconstrained fn func_3(_b: unconstrained fn(unconstrained fn(u128) -> bool) -> bool) -> i64 { + 0 +} diff --git a/test_programs/execution_success/lambda_taking_lambda_regression_8543/stdout.txt b/test_programs/execution_success/lambda_taking_lambda_regression_8543/stdout.txt new file mode 100644 index 00000000000..7d2648c8173 --- /dev/null +++ b/test_programs/execution_success/lambda_taking_lambda_regression_8543/stdout.txt @@ -0,0 +1 @@ +[lambda_taking_lambda_regression_8543] Circuit output: Field(0) \ No newline at end of file diff --git a/test_programs/execution_success/lambda_taking_lambda_with_variant/Nargo.toml b/test_programs/execution_success/lambda_taking_lambda_with_variant/Nargo.toml new file mode 100644 index 00000000000..ade33701acf --- /dev/null +++ b/test_programs/execution_success/lambda_taking_lambda_with_variant/Nargo.toml @@ -0,0 +1,6 @@ +[package] +name = "lambda_taking_lambda_with_variant" +type = "bin" +authors = [""] + +[dependencies] \ No newline at end of file diff --git a/test_programs/execution_success/lambda_taking_lambda_with_variant/src/main.nr b/test_programs/execution_success/lambda_taking_lambda_with_variant/src/main.nr new file mode 100644 index 00000000000..e045209f6e3 --- /dev/null +++ b/test_programs/execution_success/lambda_taking_lambda_with_variant/src/main.nr @@ -0,0 +1,17 @@ +// This is the same as `lambda_taking_lambda_regression_8543` except that there is +// actually a variant which has been constructed. +unconstrained fn main() -> pub i64 { + func_3(func_2) +} + +unconstrained fn func_2(a: unconstrained fn(u128) -> bool) -> bool { + a(1) +} +unconstrained fn func_3(b: unconstrained fn(unconstrained fn(u128) -> bool) -> bool) -> i64 { + let _s = b(func_1); + 0 +} + +unconstrained fn func_1(a: u128) -> bool { + a > 0 +} diff --git a/test_programs/execution_success/lambda_taking_lambda_with_variant/stdout.txt b/test_programs/execution_success/lambda_taking_lambda_with_variant/stdout.txt new file mode 100644 index 00000000000..51a6f604993 --- /dev/null +++ b/test_programs/execution_success/lambda_taking_lambda_with_variant/stdout.txt @@ -0,0 +1 @@ +[lambda_taking_lambda_with_variant] Circuit output: Field(0) \ No newline at end of file diff --git a/tooling/nargo_cli/tests/snapshots/execution_success/lambda_taking_lambda_regression_8543/execute__tests__expanded.snap b/tooling/nargo_cli/tests/snapshots/execution_success/lambda_taking_lambda_regression_8543/execute__tests__expanded.snap new file mode 100644 index 00000000000..85c9d19d020 --- /dev/null +++ b/tooling/nargo_cli/tests/snapshots/execution_success/lambda_taking_lambda_regression_8543/execute__tests__expanded.snap @@ -0,0 +1,15 @@ +--- +source: tooling/nargo_cli/tests/execute.rs +expression: expanded_code +--- +unconstrained fn main() -> pub i64 { + func_3(func_2) +} + +unconstrained fn func_2(a: unconstrained fn(u128) -> bool) -> bool { + a(1) +} + +unconstrained fn func_3(_b: unconstrained fn(unconstrained fn(u128) -> bool) -> bool) -> i64 { + 0 +} diff --git a/tooling/nargo_cli/tests/snapshots/execution_success/lambda_taking_lambda_regression_8543/execute__tests__force_brillig_false_inliner_-9223372036854775808.snap b/tooling/nargo_cli/tests/snapshots/execution_success/lambda_taking_lambda_regression_8543/execute__tests__force_brillig_false_inliner_-9223372036854775808.snap new file mode 100644 index 00000000000..668566d2e7f --- /dev/null +++ b/tooling/nargo_cli/tests/snapshots/execution_success/lambda_taking_lambda_regression_8543/execute__tests__force_brillig_false_inliner_-9223372036854775808.snap @@ -0,0 +1,43 @@ +--- +source: tooling/nargo_cli/tests/execute.rs +expression: artifact +--- +{ + "noir_version": "[noir_version]", + "hash": "[hash]", + "abi": { + "parameters": [], + "return_type": { + "abi_type": { + "kind": "integer", + "sign": "signed", + "width": 64 + }, + "visibility": "public" + }, + "error_types": { + "17843811134343075018": { + "error_kind": "string", + "string": "Stack too deep" + } + } + }, + "bytecode": [ + "func 0", + "current witness index : _0", + "private parameters indices : []", + "public parameters indices : []", + "return value indices : [_0]", + "BRILLIG CALL func 0: inputs: [], outputs: [Simple(Witness(0))]", + "unconstrained func 0", + "[Const { destination: Direct(2), bit_size: Integer(U32), value: 1 }, Const { destination: Direct(1), bit_size: Integer(U32), value: 32837 }, Const { destination: Direct(0), bit_size: Integer(U32), value: 3 }, Const { destination: Relative(1), bit_size: Integer(U32), value: 0 }, Const { destination: Relative(2), bit_size: Integer(U32), value: 0 }, CalldataCopy { destination_address: Direct(32836), size_address: Relative(1), offset_address: Relative(2) }, Call { location: 12 }, Call { location: 13 }, Mov { destination: Direct(32836), source: Relative(1) }, Const { destination: Relative(2), bit_size: Integer(U32), value: 32836 }, Const { destination: Relative(3), bit_size: Integer(U32), value: 1 }, Stop { return_data: HeapVector { pointer: Relative(2), size: Relative(3) } }, Return, Call { location: 16 }, Const { destination: Relative(1), bit_size: Integer(U64), value: 0 }, Return, Const { destination: Direct(32772), bit_size: Integer(U32), value: 30720 }, BinaryIntOp { destination: Direct(32771), op: LessThan, bit_size: U32, lhs: Direct(0), rhs: Direct(32772) }, JumpIf { condition: Direct(32771), location: 21 }, IndirectConst { destination_pointer: Direct(1), bit_size: Integer(U64), value: 17843811134343075018 }, Trap { revert_data: HeapVector { pointer: Direct(1), size: Direct(2) } }, Return]" + ], + "debug_symbols": "XY7BCoRACIbfxfMcag976FUiwiaLAXEGmwmW6N3XiQ1iL+rvp/4eMNNU1jHIEjfo+gMmDcxhHTl6zCGKdY/TwS3HrETWgge3rYRKkqGTwuxgRy7X0JZQrpxRjTYOSGbLdnAJTLU6BxPog/477qgBJ6afXIr4B82fdJP746TR01yU6qXKoKmhtdi3b/dqh7O6fQE=", + "file_map": {}, + "names": [ + "main" + ], + "brillig_names": [ + "main" + ] +} diff --git a/tooling/nargo_cli/tests/snapshots/execution_success/lambda_taking_lambda_regression_8543/execute__tests__force_brillig_false_inliner_0.snap b/tooling/nargo_cli/tests/snapshots/execution_success/lambda_taking_lambda_regression_8543/execute__tests__force_brillig_false_inliner_0.snap new file mode 100644 index 00000000000..668566d2e7f --- /dev/null +++ b/tooling/nargo_cli/tests/snapshots/execution_success/lambda_taking_lambda_regression_8543/execute__tests__force_brillig_false_inliner_0.snap @@ -0,0 +1,43 @@ +--- +source: tooling/nargo_cli/tests/execute.rs +expression: artifact +--- +{ + "noir_version": "[noir_version]", + "hash": "[hash]", + "abi": { + "parameters": [], + "return_type": { + "abi_type": { + "kind": "integer", + "sign": "signed", + "width": 64 + }, + "visibility": "public" + }, + "error_types": { + "17843811134343075018": { + "error_kind": "string", + "string": "Stack too deep" + } + } + }, + "bytecode": [ + "func 0", + "current witness index : _0", + "private parameters indices : []", + "public parameters indices : []", + "return value indices : [_0]", + "BRILLIG CALL func 0: inputs: [], outputs: [Simple(Witness(0))]", + "unconstrained func 0", + "[Const { destination: Direct(2), bit_size: Integer(U32), value: 1 }, Const { destination: Direct(1), bit_size: Integer(U32), value: 32837 }, Const { destination: Direct(0), bit_size: Integer(U32), value: 3 }, Const { destination: Relative(1), bit_size: Integer(U32), value: 0 }, Const { destination: Relative(2), bit_size: Integer(U32), value: 0 }, CalldataCopy { destination_address: Direct(32836), size_address: Relative(1), offset_address: Relative(2) }, Call { location: 12 }, Call { location: 13 }, Mov { destination: Direct(32836), source: Relative(1) }, Const { destination: Relative(2), bit_size: Integer(U32), value: 32836 }, Const { destination: Relative(3), bit_size: Integer(U32), value: 1 }, Stop { return_data: HeapVector { pointer: Relative(2), size: Relative(3) } }, Return, Call { location: 16 }, Const { destination: Relative(1), bit_size: Integer(U64), value: 0 }, Return, Const { destination: Direct(32772), bit_size: Integer(U32), value: 30720 }, BinaryIntOp { destination: Direct(32771), op: LessThan, bit_size: U32, lhs: Direct(0), rhs: Direct(32772) }, JumpIf { condition: Direct(32771), location: 21 }, IndirectConst { destination_pointer: Direct(1), bit_size: Integer(U64), value: 17843811134343075018 }, Trap { revert_data: HeapVector { pointer: Direct(1), size: Direct(2) } }, Return]" + ], + "debug_symbols": "XY7BCoRACIbfxfMcag976FUiwiaLAXEGmwmW6N3XiQ1iL+rvp/4eMNNU1jHIEjfo+gMmDcxhHTl6zCGKdY/TwS3HrETWgge3rYRKkqGTwuxgRy7X0JZQrpxRjTYOSGbLdnAJTLU6BxPog/477qgBJ6afXIr4B82fdJP746TR01yU6qXKoKmhtdi3b/dqh7O6fQE=", + "file_map": {}, + "names": [ + "main" + ], + "brillig_names": [ + "main" + ] +} diff --git a/tooling/nargo_cli/tests/snapshots/execution_success/lambda_taking_lambda_regression_8543/execute__tests__force_brillig_false_inliner_9223372036854775807.snap b/tooling/nargo_cli/tests/snapshots/execution_success/lambda_taking_lambda_regression_8543/execute__tests__force_brillig_false_inliner_9223372036854775807.snap new file mode 100644 index 00000000000..668566d2e7f --- /dev/null +++ b/tooling/nargo_cli/tests/snapshots/execution_success/lambda_taking_lambda_regression_8543/execute__tests__force_brillig_false_inliner_9223372036854775807.snap @@ -0,0 +1,43 @@ +--- +source: tooling/nargo_cli/tests/execute.rs +expression: artifact +--- +{ + "noir_version": "[noir_version]", + "hash": "[hash]", + "abi": { + "parameters": [], + "return_type": { + "abi_type": { + "kind": "integer", + "sign": "signed", + "width": 64 + }, + "visibility": "public" + }, + "error_types": { + "17843811134343075018": { + "error_kind": "string", + "string": "Stack too deep" + } + } + }, + "bytecode": [ + "func 0", + "current witness index : _0", + "private parameters indices : []", + "public parameters indices : []", + "return value indices : [_0]", + "BRILLIG CALL func 0: inputs: [], outputs: [Simple(Witness(0))]", + "unconstrained func 0", + "[Const { destination: Direct(2), bit_size: Integer(U32), value: 1 }, Const { destination: Direct(1), bit_size: Integer(U32), value: 32837 }, Const { destination: Direct(0), bit_size: Integer(U32), value: 3 }, Const { destination: Relative(1), bit_size: Integer(U32), value: 0 }, Const { destination: Relative(2), bit_size: Integer(U32), value: 0 }, CalldataCopy { destination_address: Direct(32836), size_address: Relative(1), offset_address: Relative(2) }, Call { location: 12 }, Call { location: 13 }, Mov { destination: Direct(32836), source: Relative(1) }, Const { destination: Relative(2), bit_size: Integer(U32), value: 32836 }, Const { destination: Relative(3), bit_size: Integer(U32), value: 1 }, Stop { return_data: HeapVector { pointer: Relative(2), size: Relative(3) } }, Return, Call { location: 16 }, Const { destination: Relative(1), bit_size: Integer(U64), value: 0 }, Return, Const { destination: Direct(32772), bit_size: Integer(U32), value: 30720 }, BinaryIntOp { destination: Direct(32771), op: LessThan, bit_size: U32, lhs: Direct(0), rhs: Direct(32772) }, JumpIf { condition: Direct(32771), location: 21 }, IndirectConst { destination_pointer: Direct(1), bit_size: Integer(U64), value: 17843811134343075018 }, Trap { revert_data: HeapVector { pointer: Direct(1), size: Direct(2) } }, Return]" + ], + "debug_symbols": "XY7BCoRACIbfxfMcag976FUiwiaLAXEGmwmW6N3XiQ1iL+rvp/4eMNNU1jHIEjfo+gMmDcxhHTl6zCGKdY/TwS3HrETWgge3rYRKkqGTwuxgRy7X0JZQrpxRjTYOSGbLdnAJTLU6BxPog/477qgBJ6afXIr4B82fdJP746TR01yU6qXKoKmhtdi3b/dqh7O6fQE=", + "file_map": {}, + "names": [ + "main" + ], + "brillig_names": [ + "main" + ] +} diff --git a/tooling/nargo_cli/tests/snapshots/execution_success/lambda_taking_lambda_regression_8543/execute__tests__force_brillig_true_inliner_-9223372036854775808.snap b/tooling/nargo_cli/tests/snapshots/execution_success/lambda_taking_lambda_regression_8543/execute__tests__force_brillig_true_inliner_-9223372036854775808.snap new file mode 100644 index 00000000000..668566d2e7f --- /dev/null +++ b/tooling/nargo_cli/tests/snapshots/execution_success/lambda_taking_lambda_regression_8543/execute__tests__force_brillig_true_inliner_-9223372036854775808.snap @@ -0,0 +1,43 @@ +--- +source: tooling/nargo_cli/tests/execute.rs +expression: artifact +--- +{ + "noir_version": "[noir_version]", + "hash": "[hash]", + "abi": { + "parameters": [], + "return_type": { + "abi_type": { + "kind": "integer", + "sign": "signed", + "width": 64 + }, + "visibility": "public" + }, + "error_types": { + "17843811134343075018": { + "error_kind": "string", + "string": "Stack too deep" + } + } + }, + "bytecode": [ + "func 0", + "current witness index : _0", + "private parameters indices : []", + "public parameters indices : []", + "return value indices : [_0]", + "BRILLIG CALL func 0: inputs: [], outputs: [Simple(Witness(0))]", + "unconstrained func 0", + "[Const { destination: Direct(2), bit_size: Integer(U32), value: 1 }, Const { destination: Direct(1), bit_size: Integer(U32), value: 32837 }, Const { destination: Direct(0), bit_size: Integer(U32), value: 3 }, Const { destination: Relative(1), bit_size: Integer(U32), value: 0 }, Const { destination: Relative(2), bit_size: Integer(U32), value: 0 }, CalldataCopy { destination_address: Direct(32836), size_address: Relative(1), offset_address: Relative(2) }, Call { location: 12 }, Call { location: 13 }, Mov { destination: Direct(32836), source: Relative(1) }, Const { destination: Relative(2), bit_size: Integer(U32), value: 32836 }, Const { destination: Relative(3), bit_size: Integer(U32), value: 1 }, Stop { return_data: HeapVector { pointer: Relative(2), size: Relative(3) } }, Return, Call { location: 16 }, Const { destination: Relative(1), bit_size: Integer(U64), value: 0 }, Return, Const { destination: Direct(32772), bit_size: Integer(U32), value: 30720 }, BinaryIntOp { destination: Direct(32771), op: LessThan, bit_size: U32, lhs: Direct(0), rhs: Direct(32772) }, JumpIf { condition: Direct(32771), location: 21 }, IndirectConst { destination_pointer: Direct(1), bit_size: Integer(U64), value: 17843811134343075018 }, Trap { revert_data: HeapVector { pointer: Direct(1), size: Direct(2) } }, Return]" + ], + "debug_symbols": "XY7BCoRACIbfxfMcag976FUiwiaLAXEGmwmW6N3XiQ1iL+rvp/4eMNNU1jHIEjfo+gMmDcxhHTl6zCGKdY/TwS3HrETWgge3rYRKkqGTwuxgRy7X0JZQrpxRjTYOSGbLdnAJTLU6BxPog/477qgBJ6afXIr4B82fdJP746TR01yU6qXKoKmhtdi3b/dqh7O6fQE=", + "file_map": {}, + "names": [ + "main" + ], + "brillig_names": [ + "main" + ] +} diff --git a/tooling/nargo_cli/tests/snapshots/execution_success/lambda_taking_lambda_regression_8543/execute__tests__force_brillig_true_inliner_0.snap b/tooling/nargo_cli/tests/snapshots/execution_success/lambda_taking_lambda_regression_8543/execute__tests__force_brillig_true_inliner_0.snap new file mode 100644 index 00000000000..668566d2e7f --- /dev/null +++ b/tooling/nargo_cli/tests/snapshots/execution_success/lambda_taking_lambda_regression_8543/execute__tests__force_brillig_true_inliner_0.snap @@ -0,0 +1,43 @@ +--- +source: tooling/nargo_cli/tests/execute.rs +expression: artifact +--- +{ + "noir_version": "[noir_version]", + "hash": "[hash]", + "abi": { + "parameters": [], + "return_type": { + "abi_type": { + "kind": "integer", + "sign": "signed", + "width": 64 + }, + "visibility": "public" + }, + "error_types": { + "17843811134343075018": { + "error_kind": "string", + "string": "Stack too deep" + } + } + }, + "bytecode": [ + "func 0", + "current witness index : _0", + "private parameters indices : []", + "public parameters indices : []", + "return value indices : [_0]", + "BRILLIG CALL func 0: inputs: [], outputs: [Simple(Witness(0))]", + "unconstrained func 0", + "[Const { destination: Direct(2), bit_size: Integer(U32), value: 1 }, Const { destination: Direct(1), bit_size: Integer(U32), value: 32837 }, Const { destination: Direct(0), bit_size: Integer(U32), value: 3 }, Const { destination: Relative(1), bit_size: Integer(U32), value: 0 }, Const { destination: Relative(2), bit_size: Integer(U32), value: 0 }, CalldataCopy { destination_address: Direct(32836), size_address: Relative(1), offset_address: Relative(2) }, Call { location: 12 }, Call { location: 13 }, Mov { destination: Direct(32836), source: Relative(1) }, Const { destination: Relative(2), bit_size: Integer(U32), value: 32836 }, Const { destination: Relative(3), bit_size: Integer(U32), value: 1 }, Stop { return_data: HeapVector { pointer: Relative(2), size: Relative(3) } }, Return, Call { location: 16 }, Const { destination: Relative(1), bit_size: Integer(U64), value: 0 }, Return, Const { destination: Direct(32772), bit_size: Integer(U32), value: 30720 }, BinaryIntOp { destination: Direct(32771), op: LessThan, bit_size: U32, lhs: Direct(0), rhs: Direct(32772) }, JumpIf { condition: Direct(32771), location: 21 }, IndirectConst { destination_pointer: Direct(1), bit_size: Integer(U64), value: 17843811134343075018 }, Trap { revert_data: HeapVector { pointer: Direct(1), size: Direct(2) } }, Return]" + ], + "debug_symbols": "XY7BCoRACIbfxfMcag976FUiwiaLAXEGmwmW6N3XiQ1iL+rvp/4eMNNU1jHIEjfo+gMmDcxhHTl6zCGKdY/TwS3HrETWgge3rYRKkqGTwuxgRy7X0JZQrpxRjTYOSGbLdnAJTLU6BxPog/477qgBJ6afXIr4B82fdJP746TR01yU6qXKoKmhtdi3b/dqh7O6fQE=", + "file_map": {}, + "names": [ + "main" + ], + "brillig_names": [ + "main" + ] +} diff --git a/tooling/nargo_cli/tests/snapshots/execution_success/lambda_taking_lambda_regression_8543/execute__tests__force_brillig_true_inliner_9223372036854775807.snap b/tooling/nargo_cli/tests/snapshots/execution_success/lambda_taking_lambda_regression_8543/execute__tests__force_brillig_true_inliner_9223372036854775807.snap new file mode 100644 index 00000000000..668566d2e7f --- /dev/null +++ b/tooling/nargo_cli/tests/snapshots/execution_success/lambda_taking_lambda_regression_8543/execute__tests__force_brillig_true_inliner_9223372036854775807.snap @@ -0,0 +1,43 @@ +--- +source: tooling/nargo_cli/tests/execute.rs +expression: artifact +--- +{ + "noir_version": "[noir_version]", + "hash": "[hash]", + "abi": { + "parameters": [], + "return_type": { + "abi_type": { + "kind": "integer", + "sign": "signed", + "width": 64 + }, + "visibility": "public" + }, + "error_types": { + "17843811134343075018": { + "error_kind": "string", + "string": "Stack too deep" + } + } + }, + "bytecode": [ + "func 0", + "current witness index : _0", + "private parameters indices : []", + "public parameters indices : []", + "return value indices : [_0]", + "BRILLIG CALL func 0: inputs: [], outputs: [Simple(Witness(0))]", + "unconstrained func 0", + "[Const { destination: Direct(2), bit_size: Integer(U32), value: 1 }, Const { destination: Direct(1), bit_size: Integer(U32), value: 32837 }, Const { destination: Direct(0), bit_size: Integer(U32), value: 3 }, Const { destination: Relative(1), bit_size: Integer(U32), value: 0 }, Const { destination: Relative(2), bit_size: Integer(U32), value: 0 }, CalldataCopy { destination_address: Direct(32836), size_address: Relative(1), offset_address: Relative(2) }, Call { location: 12 }, Call { location: 13 }, Mov { destination: Direct(32836), source: Relative(1) }, Const { destination: Relative(2), bit_size: Integer(U32), value: 32836 }, Const { destination: Relative(3), bit_size: Integer(U32), value: 1 }, Stop { return_data: HeapVector { pointer: Relative(2), size: Relative(3) } }, Return, Call { location: 16 }, Const { destination: Relative(1), bit_size: Integer(U64), value: 0 }, Return, Const { destination: Direct(32772), bit_size: Integer(U32), value: 30720 }, BinaryIntOp { destination: Direct(32771), op: LessThan, bit_size: U32, lhs: Direct(0), rhs: Direct(32772) }, JumpIf { condition: Direct(32771), location: 21 }, IndirectConst { destination_pointer: Direct(1), bit_size: Integer(U64), value: 17843811134343075018 }, Trap { revert_data: HeapVector { pointer: Direct(1), size: Direct(2) } }, Return]" + ], + "debug_symbols": "XY7BCoRACIbfxfMcag976FUiwiaLAXEGmwmW6N3XiQ1iL+rvp/4eMNNU1jHIEjfo+gMmDcxhHTl6zCGKdY/TwS3HrETWgge3rYRKkqGTwuxgRy7X0JZQrpxRjTYOSGbLdnAJTLU6BxPog/477qgBJ6afXIr4B82fdJP746TR01yU6qXKoKmhtdi3b/dqh7O6fQE=", + "file_map": {}, + "names": [ + "main" + ], + "brillig_names": [ + "main" + ] +} diff --git a/tooling/nargo_cli/tests/snapshots/execution_success/lambda_taking_lambda_with_variant/execute__tests__expanded.snap b/tooling/nargo_cli/tests/snapshots/execution_success/lambda_taking_lambda_with_variant/execute__tests__expanded.snap new file mode 100644 index 00000000000..96d5481bd88 --- /dev/null +++ b/tooling/nargo_cli/tests/snapshots/execution_success/lambda_taking_lambda_with_variant/execute__tests__expanded.snap @@ -0,0 +1,20 @@ +--- +source: tooling/nargo_cli/tests/execute.rs +expression: expanded_code +--- +unconstrained fn main() -> pub i64 { + func_3(func_2) +} + +unconstrained fn func_2(a: unconstrained fn(u128) -> bool) -> bool { + a(1) +} + +unconstrained fn func_3(b: unconstrained fn(unconstrained fn(u128) -> bool) -> bool) -> i64 { + let _s: bool = b(func_1); + 0 +} + +unconstrained fn func_1(a: u128) -> bool { + a > 0 +} diff --git a/tooling/nargo_cli/tests/snapshots/execution_success/lambda_taking_lambda_with_variant/execute__tests__force_brillig_false_inliner_-9223372036854775808.snap b/tooling/nargo_cli/tests/snapshots/execution_success/lambda_taking_lambda_with_variant/execute__tests__force_brillig_false_inliner_-9223372036854775808.snap new file mode 100644 index 00000000000..668566d2e7f --- /dev/null +++ b/tooling/nargo_cli/tests/snapshots/execution_success/lambda_taking_lambda_with_variant/execute__tests__force_brillig_false_inliner_-9223372036854775808.snap @@ -0,0 +1,43 @@ +--- +source: tooling/nargo_cli/tests/execute.rs +expression: artifact +--- +{ + "noir_version": "[noir_version]", + "hash": "[hash]", + "abi": { + "parameters": [], + "return_type": { + "abi_type": { + "kind": "integer", + "sign": "signed", + "width": 64 + }, + "visibility": "public" + }, + "error_types": { + "17843811134343075018": { + "error_kind": "string", + "string": "Stack too deep" + } + } + }, + "bytecode": [ + "func 0", + "current witness index : _0", + "private parameters indices : []", + "public parameters indices : []", + "return value indices : [_0]", + "BRILLIG CALL func 0: inputs: [], outputs: [Simple(Witness(0))]", + "unconstrained func 0", + "[Const { destination: Direct(2), bit_size: Integer(U32), value: 1 }, Const { destination: Direct(1), bit_size: Integer(U32), value: 32837 }, Const { destination: Direct(0), bit_size: Integer(U32), value: 3 }, Const { destination: Relative(1), bit_size: Integer(U32), value: 0 }, Const { destination: Relative(2), bit_size: Integer(U32), value: 0 }, CalldataCopy { destination_address: Direct(32836), size_address: Relative(1), offset_address: Relative(2) }, Call { location: 12 }, Call { location: 13 }, Mov { destination: Direct(32836), source: Relative(1) }, Const { destination: Relative(2), bit_size: Integer(U32), value: 32836 }, Const { destination: Relative(3), bit_size: Integer(U32), value: 1 }, Stop { return_data: HeapVector { pointer: Relative(2), size: Relative(3) } }, Return, Call { location: 16 }, Const { destination: Relative(1), bit_size: Integer(U64), value: 0 }, Return, Const { destination: Direct(32772), bit_size: Integer(U32), value: 30720 }, BinaryIntOp { destination: Direct(32771), op: LessThan, bit_size: U32, lhs: Direct(0), rhs: Direct(32772) }, JumpIf { condition: Direct(32771), location: 21 }, IndirectConst { destination_pointer: Direct(1), bit_size: Integer(U64), value: 17843811134343075018 }, Trap { revert_data: HeapVector { pointer: Direct(1), size: Direct(2) } }, Return]" + ], + "debug_symbols": "XY7BCoRACIbfxfMcag976FUiwiaLAXEGmwmW6N3XiQ1iL+rvp/4eMNNU1jHIEjfo+gMmDcxhHTl6zCGKdY/TwS3HrETWgge3rYRKkqGTwuxgRy7X0JZQrpxRjTYOSGbLdnAJTLU6BxPog/477qgBJ6afXIr4B82fdJP746TR01yU6qXKoKmhtdi3b/dqh7O6fQE=", + "file_map": {}, + "names": [ + "main" + ], + "brillig_names": [ + "main" + ] +} diff --git a/tooling/nargo_cli/tests/snapshots/execution_success/lambda_taking_lambda_with_variant/execute__tests__force_brillig_false_inliner_0.snap b/tooling/nargo_cli/tests/snapshots/execution_success/lambda_taking_lambda_with_variant/execute__tests__force_brillig_false_inliner_0.snap new file mode 100644 index 00000000000..668566d2e7f --- /dev/null +++ b/tooling/nargo_cli/tests/snapshots/execution_success/lambda_taking_lambda_with_variant/execute__tests__force_brillig_false_inliner_0.snap @@ -0,0 +1,43 @@ +--- +source: tooling/nargo_cli/tests/execute.rs +expression: artifact +--- +{ + "noir_version": "[noir_version]", + "hash": "[hash]", + "abi": { + "parameters": [], + "return_type": { + "abi_type": { + "kind": "integer", + "sign": "signed", + "width": 64 + }, + "visibility": "public" + }, + "error_types": { + "17843811134343075018": { + "error_kind": "string", + "string": "Stack too deep" + } + } + }, + "bytecode": [ + "func 0", + "current witness index : _0", + "private parameters indices : []", + "public parameters indices : []", + "return value indices : [_0]", + "BRILLIG CALL func 0: inputs: [], outputs: [Simple(Witness(0))]", + "unconstrained func 0", + "[Const { destination: Direct(2), bit_size: Integer(U32), value: 1 }, Const { destination: Direct(1), bit_size: Integer(U32), value: 32837 }, Const { destination: Direct(0), bit_size: Integer(U32), value: 3 }, Const { destination: Relative(1), bit_size: Integer(U32), value: 0 }, Const { destination: Relative(2), bit_size: Integer(U32), value: 0 }, CalldataCopy { destination_address: Direct(32836), size_address: Relative(1), offset_address: Relative(2) }, Call { location: 12 }, Call { location: 13 }, Mov { destination: Direct(32836), source: Relative(1) }, Const { destination: Relative(2), bit_size: Integer(U32), value: 32836 }, Const { destination: Relative(3), bit_size: Integer(U32), value: 1 }, Stop { return_data: HeapVector { pointer: Relative(2), size: Relative(3) } }, Return, Call { location: 16 }, Const { destination: Relative(1), bit_size: Integer(U64), value: 0 }, Return, Const { destination: Direct(32772), bit_size: Integer(U32), value: 30720 }, BinaryIntOp { destination: Direct(32771), op: LessThan, bit_size: U32, lhs: Direct(0), rhs: Direct(32772) }, JumpIf { condition: Direct(32771), location: 21 }, IndirectConst { destination_pointer: Direct(1), bit_size: Integer(U64), value: 17843811134343075018 }, Trap { revert_data: HeapVector { pointer: Direct(1), size: Direct(2) } }, Return]" + ], + "debug_symbols": "XY7BCoRACIbfxfMcag976FUiwiaLAXEGmwmW6N3XiQ1iL+rvp/4eMNNU1jHIEjfo+gMmDcxhHTl6zCGKdY/TwS3HrETWgge3rYRKkqGTwuxgRy7X0JZQrpxRjTYOSGbLdnAJTLU6BxPog/477qgBJ6afXIr4B82fdJP746TR01yU6qXKoKmhtdi3b/dqh7O6fQE=", + "file_map": {}, + "names": [ + "main" + ], + "brillig_names": [ + "main" + ] +} diff --git a/tooling/nargo_cli/tests/snapshots/execution_success/lambda_taking_lambda_with_variant/execute__tests__force_brillig_false_inliner_9223372036854775807.snap b/tooling/nargo_cli/tests/snapshots/execution_success/lambda_taking_lambda_with_variant/execute__tests__force_brillig_false_inliner_9223372036854775807.snap new file mode 100644 index 00000000000..668566d2e7f --- /dev/null +++ b/tooling/nargo_cli/tests/snapshots/execution_success/lambda_taking_lambda_with_variant/execute__tests__force_brillig_false_inliner_9223372036854775807.snap @@ -0,0 +1,43 @@ +--- +source: tooling/nargo_cli/tests/execute.rs +expression: artifact +--- +{ + "noir_version": "[noir_version]", + "hash": "[hash]", + "abi": { + "parameters": [], + "return_type": { + "abi_type": { + "kind": "integer", + "sign": "signed", + "width": 64 + }, + "visibility": "public" + }, + "error_types": { + "17843811134343075018": { + "error_kind": "string", + "string": "Stack too deep" + } + } + }, + "bytecode": [ + "func 0", + "current witness index : _0", + "private parameters indices : []", + "public parameters indices : []", + "return value indices : [_0]", + "BRILLIG CALL func 0: inputs: [], outputs: [Simple(Witness(0))]", + "unconstrained func 0", + "[Const { destination: Direct(2), bit_size: Integer(U32), value: 1 }, Const { destination: Direct(1), bit_size: Integer(U32), value: 32837 }, Const { destination: Direct(0), bit_size: Integer(U32), value: 3 }, Const { destination: Relative(1), bit_size: Integer(U32), value: 0 }, Const { destination: Relative(2), bit_size: Integer(U32), value: 0 }, CalldataCopy { destination_address: Direct(32836), size_address: Relative(1), offset_address: Relative(2) }, Call { location: 12 }, Call { location: 13 }, Mov { destination: Direct(32836), source: Relative(1) }, Const { destination: Relative(2), bit_size: Integer(U32), value: 32836 }, Const { destination: Relative(3), bit_size: Integer(U32), value: 1 }, Stop { return_data: HeapVector { pointer: Relative(2), size: Relative(3) } }, Return, Call { location: 16 }, Const { destination: Relative(1), bit_size: Integer(U64), value: 0 }, Return, Const { destination: Direct(32772), bit_size: Integer(U32), value: 30720 }, BinaryIntOp { destination: Direct(32771), op: LessThan, bit_size: U32, lhs: Direct(0), rhs: Direct(32772) }, JumpIf { condition: Direct(32771), location: 21 }, IndirectConst { destination_pointer: Direct(1), bit_size: Integer(U64), value: 17843811134343075018 }, Trap { revert_data: HeapVector { pointer: Direct(1), size: Direct(2) } }, Return]" + ], + "debug_symbols": "XY7BCoRACIbfxfMcag976FUiwiaLAXEGmwmW6N3XiQ1iL+rvp/4eMNNU1jHIEjfo+gMmDcxhHTl6zCGKdY/TwS3HrETWgge3rYRKkqGTwuxgRy7X0JZQrpxRjTYOSGbLdnAJTLU6BxPog/477qgBJ6afXIr4B82fdJP746TR01yU6qXKoKmhtdi3b/dqh7O6fQE=", + "file_map": {}, + "names": [ + "main" + ], + "brillig_names": [ + "main" + ] +} diff --git a/tooling/nargo_cli/tests/snapshots/execution_success/lambda_taking_lambda_with_variant/execute__tests__force_brillig_true_inliner_-9223372036854775808.snap b/tooling/nargo_cli/tests/snapshots/execution_success/lambda_taking_lambda_with_variant/execute__tests__force_brillig_true_inliner_-9223372036854775808.snap new file mode 100644 index 00000000000..668566d2e7f --- /dev/null +++ b/tooling/nargo_cli/tests/snapshots/execution_success/lambda_taking_lambda_with_variant/execute__tests__force_brillig_true_inliner_-9223372036854775808.snap @@ -0,0 +1,43 @@ +--- +source: tooling/nargo_cli/tests/execute.rs +expression: artifact +--- +{ + "noir_version": "[noir_version]", + "hash": "[hash]", + "abi": { + "parameters": [], + "return_type": { + "abi_type": { + "kind": "integer", + "sign": "signed", + "width": 64 + }, + "visibility": "public" + }, + "error_types": { + "17843811134343075018": { + "error_kind": "string", + "string": "Stack too deep" + } + } + }, + "bytecode": [ + "func 0", + "current witness index : _0", + "private parameters indices : []", + "public parameters indices : []", + "return value indices : [_0]", + "BRILLIG CALL func 0: inputs: [], outputs: [Simple(Witness(0))]", + "unconstrained func 0", + "[Const { destination: Direct(2), bit_size: Integer(U32), value: 1 }, Const { destination: Direct(1), bit_size: Integer(U32), value: 32837 }, Const { destination: Direct(0), bit_size: Integer(U32), value: 3 }, Const { destination: Relative(1), bit_size: Integer(U32), value: 0 }, Const { destination: Relative(2), bit_size: Integer(U32), value: 0 }, CalldataCopy { destination_address: Direct(32836), size_address: Relative(1), offset_address: Relative(2) }, Call { location: 12 }, Call { location: 13 }, Mov { destination: Direct(32836), source: Relative(1) }, Const { destination: Relative(2), bit_size: Integer(U32), value: 32836 }, Const { destination: Relative(3), bit_size: Integer(U32), value: 1 }, Stop { return_data: HeapVector { pointer: Relative(2), size: Relative(3) } }, Return, Call { location: 16 }, Const { destination: Relative(1), bit_size: Integer(U64), value: 0 }, Return, Const { destination: Direct(32772), bit_size: Integer(U32), value: 30720 }, BinaryIntOp { destination: Direct(32771), op: LessThan, bit_size: U32, lhs: Direct(0), rhs: Direct(32772) }, JumpIf { condition: Direct(32771), location: 21 }, IndirectConst { destination_pointer: Direct(1), bit_size: Integer(U64), value: 17843811134343075018 }, Trap { revert_data: HeapVector { pointer: Direct(1), size: Direct(2) } }, Return]" + ], + "debug_symbols": "XY7BCoRACIbfxfMcag976FUiwiaLAXEGmwmW6N3XiQ1iL+rvp/4eMNNU1jHIEjfo+gMmDcxhHTl6zCGKdY/TwS3HrETWgge3rYRKkqGTwuxgRy7X0JZQrpxRjTYOSGbLdnAJTLU6BxPog/477qgBJ6afXIr4B82fdJP746TR01yU6qXKoKmhtdi3b/dqh7O6fQE=", + "file_map": {}, + "names": [ + "main" + ], + "brillig_names": [ + "main" + ] +} diff --git a/tooling/nargo_cli/tests/snapshots/execution_success/lambda_taking_lambda_with_variant/execute__tests__force_brillig_true_inliner_0.snap b/tooling/nargo_cli/tests/snapshots/execution_success/lambda_taking_lambda_with_variant/execute__tests__force_brillig_true_inliner_0.snap new file mode 100644 index 00000000000..668566d2e7f --- /dev/null +++ b/tooling/nargo_cli/tests/snapshots/execution_success/lambda_taking_lambda_with_variant/execute__tests__force_brillig_true_inliner_0.snap @@ -0,0 +1,43 @@ +--- +source: tooling/nargo_cli/tests/execute.rs +expression: artifact +--- +{ + "noir_version": "[noir_version]", + "hash": "[hash]", + "abi": { + "parameters": [], + "return_type": { + "abi_type": { + "kind": "integer", + "sign": "signed", + "width": 64 + }, + "visibility": "public" + }, + "error_types": { + "17843811134343075018": { + "error_kind": "string", + "string": "Stack too deep" + } + } + }, + "bytecode": [ + "func 0", + "current witness index : _0", + "private parameters indices : []", + "public parameters indices : []", + "return value indices : [_0]", + "BRILLIG CALL func 0: inputs: [], outputs: [Simple(Witness(0))]", + "unconstrained func 0", + "[Const { destination: Direct(2), bit_size: Integer(U32), value: 1 }, Const { destination: Direct(1), bit_size: Integer(U32), value: 32837 }, Const { destination: Direct(0), bit_size: Integer(U32), value: 3 }, Const { destination: Relative(1), bit_size: Integer(U32), value: 0 }, Const { destination: Relative(2), bit_size: Integer(U32), value: 0 }, CalldataCopy { destination_address: Direct(32836), size_address: Relative(1), offset_address: Relative(2) }, Call { location: 12 }, Call { location: 13 }, Mov { destination: Direct(32836), source: Relative(1) }, Const { destination: Relative(2), bit_size: Integer(U32), value: 32836 }, Const { destination: Relative(3), bit_size: Integer(U32), value: 1 }, Stop { return_data: HeapVector { pointer: Relative(2), size: Relative(3) } }, Return, Call { location: 16 }, Const { destination: Relative(1), bit_size: Integer(U64), value: 0 }, Return, Const { destination: Direct(32772), bit_size: Integer(U32), value: 30720 }, BinaryIntOp { destination: Direct(32771), op: LessThan, bit_size: U32, lhs: Direct(0), rhs: Direct(32772) }, JumpIf { condition: Direct(32771), location: 21 }, IndirectConst { destination_pointer: Direct(1), bit_size: Integer(U64), value: 17843811134343075018 }, Trap { revert_data: HeapVector { pointer: Direct(1), size: Direct(2) } }, Return]" + ], + "debug_symbols": "XY7BCoRACIbfxfMcag976FUiwiaLAXEGmwmW6N3XiQ1iL+rvp/4eMNNU1jHIEjfo+gMmDcxhHTl6zCGKdY/TwS3HrETWgge3rYRKkqGTwuxgRy7X0JZQrpxRjTYOSGbLdnAJTLU6BxPog/477qgBJ6afXIr4B82fdJP746TR01yU6qXKoKmhtdi3b/dqh7O6fQE=", + "file_map": {}, + "names": [ + "main" + ], + "brillig_names": [ + "main" + ] +} diff --git a/tooling/nargo_cli/tests/snapshots/execution_success/lambda_taking_lambda_with_variant/execute__tests__force_brillig_true_inliner_9223372036854775807.snap b/tooling/nargo_cli/tests/snapshots/execution_success/lambda_taking_lambda_with_variant/execute__tests__force_brillig_true_inliner_9223372036854775807.snap new file mode 100644 index 00000000000..668566d2e7f --- /dev/null +++ b/tooling/nargo_cli/tests/snapshots/execution_success/lambda_taking_lambda_with_variant/execute__tests__force_brillig_true_inliner_9223372036854775807.snap @@ -0,0 +1,43 @@ +--- +source: tooling/nargo_cli/tests/execute.rs +expression: artifact +--- +{ + "noir_version": "[noir_version]", + "hash": "[hash]", + "abi": { + "parameters": [], + "return_type": { + "abi_type": { + "kind": "integer", + "sign": "signed", + "width": 64 + }, + "visibility": "public" + }, + "error_types": { + "17843811134343075018": { + "error_kind": "string", + "string": "Stack too deep" + } + } + }, + "bytecode": [ + "func 0", + "current witness index : _0", + "private parameters indices : []", + "public parameters indices : []", + "return value indices : [_0]", + "BRILLIG CALL func 0: inputs: [], outputs: [Simple(Witness(0))]", + "unconstrained func 0", + "[Const { destination: Direct(2), bit_size: Integer(U32), value: 1 }, Const { destination: Direct(1), bit_size: Integer(U32), value: 32837 }, Const { destination: Direct(0), bit_size: Integer(U32), value: 3 }, Const { destination: Relative(1), bit_size: Integer(U32), value: 0 }, Const { destination: Relative(2), bit_size: Integer(U32), value: 0 }, CalldataCopy { destination_address: Direct(32836), size_address: Relative(1), offset_address: Relative(2) }, Call { location: 12 }, Call { location: 13 }, Mov { destination: Direct(32836), source: Relative(1) }, Const { destination: Relative(2), bit_size: Integer(U32), value: 32836 }, Const { destination: Relative(3), bit_size: Integer(U32), value: 1 }, Stop { return_data: HeapVector { pointer: Relative(2), size: Relative(3) } }, Return, Call { location: 16 }, Const { destination: Relative(1), bit_size: Integer(U64), value: 0 }, Return, Const { destination: Direct(32772), bit_size: Integer(U32), value: 30720 }, BinaryIntOp { destination: Direct(32771), op: LessThan, bit_size: U32, lhs: Direct(0), rhs: Direct(32772) }, JumpIf { condition: Direct(32771), location: 21 }, IndirectConst { destination_pointer: Direct(1), bit_size: Integer(U64), value: 17843811134343075018 }, Trap { revert_data: HeapVector { pointer: Direct(1), size: Direct(2) } }, Return]" + ], + "debug_symbols": "XY7BCoRACIbfxfMcag976FUiwiaLAXEGmwmW6N3XiQ1iL+rvp/4eMNNU1jHIEjfo+gMmDcxhHTl6zCGKdY/TwS3HrETWgge3rYRKkqGTwuxgRy7X0JZQrpxRjTYOSGbLdnAJTLU6BxPog/477qgBJ6afXIr4B82fdJP746TR01yU6qXKoKmhtdi3b/dqh7O6fQE=", + "file_map": {}, + "names": [ + "main" + ], + "brillig_names": [ + "main" + ] +}