From 04c89d2581f3f73073bb0ab83d37a853c638959f Mon Sep 17 00:00:00 2001 From: Maxim Vezenov Date: Thu, 13 Jul 2023 16:38:42 +0100 Subject: [PATCH] fix(brillig_gen): Pass correct size of complex types input for brillig foreign calls (#1922) fix size of HeapArray passed to brillig foreign calls --- .../src/brillig/brillig_gen/brillig_block.rs | 7 ++++--- crates/noirc_frontend/src/parser/parser.rs | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/crates/noirc_evaluator/src/brillig/brillig_gen/brillig_block.rs b/crates/noirc_evaluator/src/brillig/brillig_gen/brillig_block.rs index 7e8865328aa..a5193a0369a 100644 --- a/crates/noirc_evaluator/src/brillig/brillig_gen/brillig_block.rs +++ b/crates/noirc_evaluator/src/brillig/brillig_gen/brillig_block.rs @@ -471,9 +471,10 @@ impl<'block> BrilligBlock<'block> { let typ = dfg[value_id].get_type(); match typ { Type::Numeric(_) => RegisterOrMemory::RegisterIndex(register_index), - Type::Array(_, size) => { - RegisterOrMemory::HeapArray(HeapArray { pointer: register_index, size }) - } + Type::Array(..) => RegisterOrMemory::HeapArray(HeapArray { + pointer: register_index, + size: compute_size_of_type(&typ), + }), _ => { unreachable!("type not supported for conversion into brillig register") } diff --git a/crates/noirc_frontend/src/parser/parser.rs b/crates/noirc_frontend/src/parser/parser.rs index 85260cdb202..a9617e3ab90 100644 --- a/crates/noirc_frontend/src/parser/parser.rs +++ b/crates/noirc_frontend/src/parser/parser.rs @@ -188,7 +188,7 @@ fn function_definition(allow_self: bool) -> impl NoirParser { }) } -/// function_modifiers: 'unconstrained'? 'open'? 'internal'? +/// function_modifiers: 'unconstrained'? 'open'? 'internal'? /// /// returns (is_unconstrained, is_open, is_internal) for whether each keyword was present fn function_modifiers() -> impl NoirParser<(bool, bool, bool)> {