From 6545e6dea157d5406937126afd3dff8e00af871c Mon Sep 17 00:00:00 2001 From: benesjan Date: Sun, 8 Mar 2026 08:16:13 +0000 Subject: [PATCH] chore: add stable error link for direct function invocation errors Adds https://docs.aztec.network/errors/6 to the compile-time error shown when developers try to directly call contract functions. The link redirects to the calling_contracts documentation page. Also adds the error to the debugging troubleshooting table. Co-Authored-By: Claude Opus 4.6 --- docs/docs-developers/docs/aztec-nr/debugging.md | 1 + docs/netlify.toml | 5 +++++ .../aztec/src/macros/internals_functions_generation/mod.nr | 5 ++--- .../panic_on_direct_private_external_fn_call/expected_error | 2 +- .../panic_on_direct_private_internal_fn_call/expected_error | 2 +- .../panic_on_direct_public_external_fn_call/expected_error | 2 +- .../panic_on_direct_public_internal_fn_call/expected_error | 2 +- .../panic_on_direct_utility_external_fn_call/expected_error | 2 +- 8 files changed, 13 insertions(+), 8 deletions(-) diff --git a/docs/docs-developers/docs/aztec-nr/debugging.md b/docs/docs-developers/docs/aztec-nr/debugging.md index 703e9d8138d0..cd1d9ede405c 100644 --- a/docs/docs-developers/docs/aztec-nr/debugging.md +++ b/docs/docs-developers/docs/aztec-nr/debugging.md @@ -94,6 +94,7 @@ LOG_LEVEL="info;debug:simulator:client_execution_context;debug:simulator:client_ | `Public state writes only supported in public functions` | Move state writes to public functions | | `Unknown contract 0x0` | Call `wallet.registerContract(...)` to register contract | | `No public key registered for address` | Call `wallet.registerSender(...)` | +| `Direct invocation of ... functions is not supported` | Use `self.call()`, `self.view()`, or `self.enqueue()` to [call contract functions](framework-description/calling_contracts.md) | | `Failed to solve brillig function` | Check function parameters and note validity | ### Circuit Errors diff --git a/docs/netlify.toml b/docs/netlify.toml index 7b4b052257b3..0019b6cb4143 100644 --- a/docs/netlify.toml +++ b/docs/netlify.toml @@ -791,3 +791,8 @@ from = "/errors/5" to = "/aztec-nr-api/nightly/noir_aztec/macros/events/fn.event.html" +[[redirects]] + # Aztec-nr: direct invocation of contract functions is not supported + from = "/errors/6" + to = "/developers/docs/aztec-nr/framework-description/calling_contracts" + diff --git a/noir-projects/aztec-nr/aztec/src/macros/internals_functions_generation/mod.nr b/noir-projects/aztec-nr/aztec/src/macros/internals_functions_generation/mod.nr index 276f4073b2b0..a1b3f9f8efe5 100644 --- a/noir-projects/aztec-nr/aztec/src/macros/internals_functions_generation/mod.nr +++ b/noir-projects/aztec-nr/aztec/src/macros/internals_functions_generation/mod.nr @@ -23,9 +23,8 @@ comptime fn make_functions_uncallable(functions: [FunctionDefinition let name = function.name(); // The body of the function will contain a static_assert(false, ...) to prevent the function from being called // directly and a std::mem::zeroed() to make the compilation fail on the static_assert and not on a missing - // return value. TODO(benesjan): Add a link to the documentation for instructions on the proper invocation of - // functions. - let error_message = f"{error_message_template}{name}. See documentation for instructions on the proper invocation of functions."; + // return value. + let error_message = f"{error_message_template}{name}. See https://docs.aztec.network/errors/6"; let body = f"{{ std::static_assert(false, \"{error_message}\"); std::mem::zeroed() }}".quoted_contents(); let body_expr = body.as_expr().expect(f"Body is not an expression: {body}"); diff --git a/noir-projects/noir-contracts-comp-failures/contracts/panic_on_direct_private_external_fn_call/expected_error b/noir-projects/noir-contracts-comp-failures/contracts/panic_on_direct_private_external_fn_call/expected_error index 10f96dc14596..03dcdf55e48b 100644 --- a/noir-projects/noir-contracts-comp-failures/contracts/panic_on_direct_private_external_fn_call/expected_error +++ b/noir-projects/noir-contracts-comp-failures/contracts/panic_on_direct_private_external_fn_call/expected_error @@ -1 +1 @@ -Direct invocation of private functions is not supported. You attempted to call arbitrary_external_function. See documentation for instructions on the proper invocation of functions. +Direct invocation of private functions is not supported. You attempted to call arbitrary_external_function. See https://docs.aztec.network/errors/6 diff --git a/noir-projects/noir-contracts-comp-failures/contracts/panic_on_direct_private_internal_fn_call/expected_error b/noir-projects/noir-contracts-comp-failures/contracts/panic_on_direct_private_internal_fn_call/expected_error index 9a25b891f016..70eb1d78dfed 100644 --- a/noir-projects/noir-contracts-comp-failures/contracts/panic_on_direct_private_internal_fn_call/expected_error +++ b/noir-projects/noir-contracts-comp-failures/contracts/panic_on_direct_private_internal_fn_call/expected_error @@ -1 +1 @@ -Direct invocation of private internal functions is not supported. You attempted to call arbitrary_private_function. See documentation for instructions on the proper invocation of functions. +Direct invocation of private internal functions is not supported. You attempted to call arbitrary_private_function. See https://docs.aztec.network/errors/6 diff --git a/noir-projects/noir-contracts-comp-failures/contracts/panic_on_direct_public_external_fn_call/expected_error b/noir-projects/noir-contracts-comp-failures/contracts/panic_on_direct_public_external_fn_call/expected_error index 21f3f0f154ee..b698579729a9 100644 --- a/noir-projects/noir-contracts-comp-failures/contracts/panic_on_direct_public_external_fn_call/expected_error +++ b/noir-projects/noir-contracts-comp-failures/contracts/panic_on_direct_public_external_fn_call/expected_error @@ -1 +1 @@ -Direct invocation of public functions is not supported. You attempted to call arbitrary_external_function. See documentation for instructions on the proper invocation of functions. +Direct invocation of public functions is not supported. You attempted to call arbitrary_external_function. See https://docs.aztec.network/errors/6 diff --git a/noir-projects/noir-contracts-comp-failures/contracts/panic_on_direct_public_internal_fn_call/expected_error b/noir-projects/noir-contracts-comp-failures/contracts/panic_on_direct_public_internal_fn_call/expected_error index 742fcd7af6e0..b50d8f6b8a7e 100644 --- a/noir-projects/noir-contracts-comp-failures/contracts/panic_on_direct_public_internal_fn_call/expected_error +++ b/noir-projects/noir-contracts-comp-failures/contracts/panic_on_direct_public_internal_fn_call/expected_error @@ -1 +1 @@ -Direct invocation of public internal functions is not supported. You attempted to call arbitrary_public_function. See documentation for instructions on the proper invocation of functions. +Direct invocation of public internal functions is not supported. You attempted to call arbitrary_public_function. See https://docs.aztec.network/errors/6 diff --git a/noir-projects/noir-contracts-comp-failures/contracts/panic_on_direct_utility_external_fn_call/expected_error b/noir-projects/noir-contracts-comp-failures/contracts/panic_on_direct_utility_external_fn_call/expected_error index 1181354a9530..23529a516337 100644 --- a/noir-projects/noir-contracts-comp-failures/contracts/panic_on_direct_utility_external_fn_call/expected_error +++ b/noir-projects/noir-contracts-comp-failures/contracts/panic_on_direct_utility_external_fn_call/expected_error @@ -1 +1 @@ -Calling utility functions directly from within the contract is not supported. You attempted to call arbitrary_external_function. See documentation for instructions on the proper invocation of functions. +Calling utility functions directly from within the contract is not supported. You attempted to call arbitrary_external_function. See https://docs.aztec.network/errors/6