From 4adda8a459422bd23a7c7ede09828170c29b89ae Mon Sep 17 00:00:00 2001 From: Maxim Vezenov Date: Mon, 19 May 2025 14:53:10 +0000 Subject: [PATCH 1/2] hot fix to allow empty array input --- compiler/noirc_frontend/src/hir_def/types.rs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/compiler/noirc_frontend/src/hir_def/types.rs b/compiler/noirc_frontend/src/hir_def/types.rs index fe347661195..50093e9cdcb 100644 --- a/compiler/noirc_frontend/src/hir_def/types.rs +++ b/compiler/noirc_frontend/src/hir_def/types.rs @@ -1299,7 +1299,7 @@ impl Type { } Type::Array(length, element) => { - self.array_or_string_len_is_not_zero() + (Self::should_allow_zero_sized_input() || self.array_or_string_len_is_not_zero()) && length.is_valid_for_program_input() && element.is_valid_for_program_input() } @@ -1322,6 +1322,14 @@ impl Type { } } + /// Check if it is okay to allow for zero-sized input (e..g zero-sized arrays) to a program. + /// This behavior is not well defined and is banned by default. + /// However, this ban is a breaking change for some dependent projects so this override + /// is provided until those projects migrate away from using zero-sized array input (e.g. https://github.com/AztecProtocol/aztec-packages/issues/14388). + fn should_allow_zero_sized_input() -> bool { + std::env::var("ALLOW_EMPTY_INPUT").ok().map(|v| v == "1" || v == "true").unwrap_or_default() + } + /// Empty arrays and strings (which are arrays under the hood) are disallowed /// as input to program entry points. /// From f25d7c62442bd6630cb45d587a05a3463c83928d Mon Sep 17 00:00:00 2001 From: Maxim Vezenov Date: Mon, 19 May 2025 14:58:26 +0000 Subject: [PATCH 2/2] fix doc link --- compiler/noirc_frontend/src/hir_def/types.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/compiler/noirc_frontend/src/hir_def/types.rs b/compiler/noirc_frontend/src/hir_def/types.rs index 50093e9cdcb..8fca878a6d7 100644 --- a/compiler/noirc_frontend/src/hir_def/types.rs +++ b/compiler/noirc_frontend/src/hir_def/types.rs @@ -1325,7 +1325,7 @@ impl Type { /// Check if it is okay to allow for zero-sized input (e..g zero-sized arrays) to a program. /// This behavior is not well defined and is banned by default. /// However, this ban is a breaking change for some dependent projects so this override - /// is provided until those projects migrate away from using zero-sized array input (e.g. https://github.com/AztecProtocol/aztec-packages/issues/14388). + /// is provided until those projects migrate away from using zero-sized array input (e.g. ). fn should_allow_zero_sized_input() -> bool { std::env::var("ALLOW_EMPTY_INPUT").ok().map(|v| v == "1" || v == "true").unwrap_or_default() }