From ae8e5263b87aaf8249a7a672ceef23553a374966 Mon Sep 17 00:00:00 2001 From: Akosh Farkash Date: Wed, 14 May 2025 11:38:41 +0100 Subject: [PATCH 1/2] Fix can_be_main to be recursive --- tooling/ast_fuzzer/src/program/mod.rs | 3 +++ tooling/ast_fuzzer/src/program/types.rs | 7 +++++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/tooling/ast_fuzzer/src/program/mod.rs b/tooling/ast_fuzzer/src/program/mod.rs index e9f3453d165..79ebb5fe280 100644 --- a/tooling/ast_fuzzer/src/program/mod.rs +++ b/tooling/ast_fuzzer/src/program/mod.rs @@ -425,6 +425,9 @@ impl Context { break; } } + if is_main { + println!("TYPE FOR MAIN: {typ}"); + } self.types.insert(typ.clone()); Ok(typ) diff --git a/tooling/ast_fuzzer/src/program/types.rs b/tooling/ast_fuzzer/src/program/types.rs index eef9afc3ee7..b8ad7a158d5 100644 --- a/tooling/ast_fuzzer/src/program/types.rs +++ b/tooling/ast_fuzzer/src/program/types.rs @@ -42,8 +42,11 @@ pub(crate) fn can_be_global(typ: &Type) -> bool { /// as well as part of the databus. They are not expected in real programs as they don't do anything useful. pub(crate) fn can_be_main(typ: &Type) -> bool { match typ { - Type::Array(size, _) | Type::String(size) => *size > 0, - _ => true, + Type::String(size) => *size > 0, + Type::Array(size, typ) => *size > 0 && can_be_main(typ), + Type::Tuple(types) => types.iter().all(can_be_main), + Type::Bool | Type::Field | Type::Integer(_, _) => true, + _ => false, } } From 9823f93d0170b0d95404dc050114dfe0e284e5ec Mon Sep 17 00:00:00 2001 From: Akosh Farkash Date: Wed, 14 May 2025 11:45:12 +0100 Subject: [PATCH 2/2] Update tooling/ast_fuzzer/src/program/mod.rs Co-authored-by: Tom French <15848336+TomAFrench@users.noreply.github.com> --- tooling/ast_fuzzer/src/program/mod.rs | 3 --- 1 file changed, 3 deletions(-) diff --git a/tooling/ast_fuzzer/src/program/mod.rs b/tooling/ast_fuzzer/src/program/mod.rs index 79ebb5fe280..e9f3453d165 100644 --- a/tooling/ast_fuzzer/src/program/mod.rs +++ b/tooling/ast_fuzzer/src/program/mod.rs @@ -425,9 +425,6 @@ impl Context { break; } } - if is_main { - println!("TYPE FOR MAIN: {typ}"); - } self.types.insert(typ.clone()); Ok(typ)