diff --git a/changelogs/unreleased/910-schaeff b/changelogs/unreleased/910-schaeff new file mode 100644 index 00000000..276e56fd --- /dev/null +++ b/changelogs/unreleased/910-schaeff @@ -0,0 +1 @@ +Fix access to constant in local function call \ No newline at end of file diff --git a/zokrates_cli/examples/constant_in_sig.zok b/zokrates_cli/examples/constant_in_sig.zok new file mode 100644 index 00000000..eed5f098 --- /dev/null +++ b/zokrates_cli/examples/constant_in_sig.zok @@ -0,0 +1,7 @@ +const u32 N = 1 +def foo(bool[N] arr) -> bool: + return true + +def main(bool[N] arr): + assert(foo(arr)) + return \ No newline at end of file diff --git a/zokrates_core/src/typed_absy/folder.rs b/zokrates_core/src/typed_absy/folder.rs index c7ff3f95..d80b3bca 100644 --- a/zokrates_core/src/typed_absy/folder.rs +++ b/zokrates_core/src/typed_absy/folder.rs @@ -830,7 +830,7 @@ pub fn fold_function_call_expression< e: FunctionCallExpression<'ast, T, E>, ) -> FunctionCallOrExpression<'ast, T, E> { FunctionCallOrExpression::FunctionCall(FunctionCallExpression::new( - e.function_key, + f.fold_declaration_function_key(e.function_key), e.generics .into_iter() .map(|g| g.map(|g| f.fold_uint_expression(g))) diff --git a/zokrates_core/src/typed_absy/result_folder.rs b/zokrates_core/src/typed_absy/result_folder.rs index ad712694..bdb334b1 100644 --- a/zokrates_core/src/typed_absy/result_folder.rs +++ b/zokrates_core/src/typed_absy/result_folder.rs @@ -632,7 +632,7 @@ pub fn fold_function_call_expression< e: FunctionCallExpression<'ast, T, E>, ) -> Result, F::Error> { Ok(FunctionCallOrExpression::Expression(E::function_call( - e.function_key, + f.fold_declaration_function_key(e.function_key)?, e.generics .into_iter() .map(|g| g.map(|g| f.fold_uint_expression(g)).transpose())