diff --git a/compiler/noirc_frontend/src/elaborator/mod.rs b/compiler/noirc_frontend/src/elaborator/mod.rs index 91d6ba71927..dc99ceae2f0 100644 --- a/compiler/noirc_frontend/src/elaborator/mod.rs +++ b/compiler/noirc_frontend/src/elaborator/mod.rs @@ -1302,9 +1302,12 @@ impl<'context> Elaborator<'context> { for (local_module, id, func) in &mut function_set.functions { self.local_module = *local_module; + let was_in_contract = self.in_contract; + self.in_contract = self.module_id().module(self.def_maps).is_contract; self.recover_generics(|this| { this.define_function_meta(func, *id, false); }); + self.in_contract = was_in_contract; } } diff --git a/test_programs/compile_success_contract/recursive_method/Nargo.toml b/test_programs/compile_success_contract/recursive_method/Nargo.toml new file mode 100644 index 00000000000..8142e5b3278 --- /dev/null +++ b/test_programs/compile_success_contract/recursive_method/Nargo.toml @@ -0,0 +1,6 @@ +[package] +name = "recursive_method" +type = "contract" +authors = [""] + +[dependencies] diff --git a/test_programs/compile_success_contract/recursive_method/src/main.nr b/test_programs/compile_success_contract/recursive_method/src/main.nr new file mode 100644 index 00000000000..6fd4bf3338d --- /dev/null +++ b/test_programs/compile_success_contract/recursive_method/src/main.nr @@ -0,0 +1,6 @@ +contract Foo { + #[recursive] + fn contract_entrypoint() -> pub Field { + 1 + } +}