From cf7fb097fe3dcbe298c5c8d499648d6848c3dc70 Mon Sep 17 00:00:00 2001 From: Tom French Date: Thu, 20 Jun 2024 19:46:19 +0100 Subject: [PATCH] fix: fix usage of `#[abi(tag)] attribute with elaborator --- compiler/noirc_frontend/src/elaborator/mod.rs | 2 +- .../compile_success_contract/abi_attribute/Nargo.toml | 6 ++++++ .../compile_success_contract/abi_attribute/src/main.nr | 4 ++++ 3 files changed, 11 insertions(+), 1 deletion(-) create mode 100644 test_programs/compile_success_contract/abi_attribute/Nargo.toml create mode 100644 test_programs/compile_success_contract/abi_attribute/src/main.nr diff --git a/compiler/noirc_frontend/src/elaborator/mod.rs b/compiler/noirc_frontend/src/elaborator/mod.rs index dc99ceae2f0..31c40815c36 100644 --- a/compiler/noirc_frontend/src/elaborator/mod.rs +++ b/compiler/noirc_frontend/src/elaborator/mod.rs @@ -1190,7 +1190,7 @@ impl<'context> Elaborator<'context> { self.current_item = Some(DependencyId::Global(global_id)); let let_stmt = global.stmt_def; - if !self.in_contract + if !self.module_id().module(self.def_maps).is_contract && let_stmt.attributes.iter().any(|attr| matches!(attr, SecondaryAttribute::Abi(_))) { let span = let_stmt.pattern.span(); diff --git a/test_programs/compile_success_contract/abi_attribute/Nargo.toml b/test_programs/compile_success_contract/abi_attribute/Nargo.toml new file mode 100644 index 00000000000..56fa88ccb68 --- /dev/null +++ b/test_programs/compile_success_contract/abi_attribute/Nargo.toml @@ -0,0 +1,6 @@ +[package] +name = "abi_attribute" +type = "contract" +authors = [""] + +[dependencies] diff --git a/test_programs/compile_success_contract/abi_attribute/src/main.nr b/test_programs/compile_success_contract/abi_attribute/src/main.nr new file mode 100644 index 00000000000..1ac63775908 --- /dev/null +++ b/test_programs/compile_success_contract/abi_attribute/src/main.nr @@ -0,0 +1,4 @@ +contract Foo { + #[abi(foo)] + global foo: Field = 42; +}