From b9c9c19af129ad2ffbd7df050a3bb2339f7dd3cb Mon Sep 17 00:00:00 2001 From: guipublic Date: Fri, 6 Oct 2023 08:00:33 +0000 Subject: [PATCH 1/5] disable modulo for fields --- compiler/noirc_frontend/src/ast/expression.rs | 4 ++++ compiler/noirc_frontend/src/hir/type_check/errors.rs | 5 ++++- compiler/noirc_frontend/src/hir/type_check/expr.rs | 3 +++ compiler/noirc_frontend/src/hir_def/expr.rs | 4 ++++ 4 files changed, 15 insertions(+), 1 deletion(-) diff --git a/compiler/noirc_frontend/src/ast/expression.rs b/compiler/noirc_frontend/src/ast/expression.rs index 213bdd3fefb..d1d71112de0 100644 --- a/compiler/noirc_frontend/src/ast/expression.rs +++ b/compiler/noirc_frontend/src/ast/expression.rs @@ -273,6 +273,10 @@ impl BinaryOpKind { pub fn is_bit_shift(&self) -> bool { matches!(self, BinaryOpKind::ShiftRight | BinaryOpKind::ShiftLeft) } + + pub fn is_modulo(&self) -> bool { + matches!(self, BinaryOpKind::Modulo) + } } #[derive(PartialEq, PartialOrd, Eq, Ord, Hash, Debug, Copy, Clone)] diff --git a/compiler/noirc_frontend/src/hir/type_check/errors.rs b/compiler/noirc_frontend/src/hir/type_check/errors.rs index 41e0e8e0079..b2b360dc81e 100644 --- a/compiler/noirc_frontend/src/hir/type_check/errors.rs +++ b/compiler/noirc_frontend/src/hir/type_check/errors.rs @@ -78,6 +78,8 @@ pub enum TypeCheckError { IntegerTypeMismatch { typ: Type, span: Span }, #[error("Cannot use an integer and a Field in a binary operation, try converting the Field into an integer first")] IntegerAndFieldBinaryOperation { span: Span }, + #[error("Cannot do modulo on Fields, try casting to an integer first")] + FieldModulo { span: Span }, #[error("Fields cannot be compared, try casting to an integer first")] FieldComparison { span: Span }, #[error("The number of bits to use for this bitwise operation is ambiguous. Either the operand's type or return type should be specified")] @@ -195,7 +197,8 @@ impl From for Diagnostic { | TypeCheckError::FieldComparison { span, .. } | TypeCheckError::AmbiguousBitWidth { span, .. } | TypeCheckError::IntegerAndFieldBinaryOperation { span } - | TypeCheckError::OverflowingAssignment { span, .. } => { + | TypeCheckError::OverflowingAssignment { span, .. } + | TypeCheckError::FieldModulo { span } => { Diagnostic::simple_error(error.to_string(), String::new(), span) } TypeCheckError::PublicReturnType { typ, span } => Diagnostic::simple_error( diff --git a/compiler/noirc_frontend/src/hir/type_check/expr.rs b/compiler/noirc_frontend/src/hir/type_check/expr.rs index 7eb4dd0184f..c63fa1cf9eb 100644 --- a/compiler/noirc_frontend/src/hir/type_check/expr.rs +++ b/compiler/noirc_frontend/src/hir/type_check/expr.rs @@ -1046,6 +1046,9 @@ impl<'interner> TypeChecker<'interner> { if op.is_bitwise() { return Err(TypeCheckError::InvalidBitwiseOperationOnField { span }); } + if op.is_modulo() { + return Err(TypeCheckError::FieldModulo { span }); + } Ok(FieldElement) } diff --git a/compiler/noirc_frontend/src/hir_def/expr.rs b/compiler/noirc_frontend/src/hir_def/expr.rs index 15d4b12d30b..157e424bc95 100644 --- a/compiler/noirc_frontend/src/hir_def/expr.rs +++ b/compiler/noirc_frontend/src/hir_def/expr.rs @@ -68,6 +68,10 @@ impl HirBinaryOp { pub fn is_bit_shift(&self) -> bool { self.kind.is_bit_shift() } + + pub fn is_modulo(&self) -> bool { + self.kind.is_modulo() + } } #[derive(Debug, Clone)] From 6174f7fc26fedc29be103a9f00d3abbb50545906 Mon Sep 17 00:00:00 2001 From: guipublic Date: Mon, 9 Oct 2023 09:27:31 +0000 Subject: [PATCH 2/5] add test case and catch another case --- compiler/noirc_frontend/src/hir/type_check/expr.rs | 12 ++++++++---- .../tests/compile_failure/field_modulo/Nargo.toml | 7 +++++++ .../tests/compile_failure/field_modulo/src/main.nr | 4 ++++ 3 files changed, 19 insertions(+), 4 deletions(-) create mode 100644 tooling/nargo_cli/tests/compile_failure/field_modulo/Nargo.toml create mode 100644 tooling/nargo_cli/tests/compile_failure/field_modulo/src/main.nr diff --git a/compiler/noirc_frontend/src/hir/type_check/expr.rs b/compiler/noirc_frontend/src/hir/type_check/expr.rs index c63fa1cf9eb..09bc1bacc7f 100644 --- a/compiler/noirc_frontend/src/hir/type_check/expr.rs +++ b/compiler/noirc_frontend/src/hir/type_check/expr.rs @@ -11,7 +11,7 @@ use crate::{ types::Type, }, node_interner::{DefinitionKind, ExprId, FuncId, TraitMethodId}, - Signedness, TypeBinding, TypeVariableKind, UnaryOp, + BinaryOpKind, Signedness, TypeBinding, TypeVariableKind, UnaryOp, }; use super::{errors::TypeCheckError, TypeChecker}; @@ -966,8 +966,8 @@ impl<'interner> TypeChecker<'interner> { if let TypeBinding::Bound(binding) = &*int.borrow() { return self.infix_operand_type_rules(binding, op, other, span); } - - if op.is_bitwise() && (other.is_bindable() || other.is_field()) { + if (op.is_modulo() || op.is_bitwise()) && (other.is_bindable() || other.is_field()) + { let other = other.follow_bindings(); let kind = op.kind; // This will be an error if these types later resolve to a Field, or stay @@ -975,7 +975,11 @@ impl<'interner> TypeChecker<'interner> { // finishes resolving so we can still allow cases like `let x: u8 = 1 << 2;`. self.push_delayed_type_check(Box::new(move || { if other.is_field() { - Err(TypeCheckError::InvalidBitwiseOperationOnField { span }) + if kind == BinaryOpKind::Modulo { + Err(TypeCheckError::FieldModulo { span }) + } else { + Err(TypeCheckError::InvalidBitwiseOperationOnField { span }) + } } else if other.is_bindable() { Err(TypeCheckError::AmbiguousBitWidth { span }) } else if kind.is_bit_shift() && other.is_signed() { diff --git a/tooling/nargo_cli/tests/compile_failure/field_modulo/Nargo.toml b/tooling/nargo_cli/tests/compile_failure/field_modulo/Nargo.toml new file mode 100644 index 00000000000..f6bc2dd70e2 --- /dev/null +++ b/tooling/nargo_cli/tests/compile_failure/field_modulo/Nargo.toml @@ -0,0 +1,7 @@ +[package] +name = "field_modulo" +type = "bin" +authors = [""] +compiler_version = "0.9.0" + +[dependencies] \ No newline at end of file diff --git a/tooling/nargo_cli/tests/compile_failure/field_modulo/src/main.nr b/tooling/nargo_cli/tests/compile_failure/field_modulo/src/main.nr new file mode 100644 index 00000000000..b27ba0892b3 --- /dev/null +++ b/tooling/nargo_cli/tests/compile_failure/field_modulo/src/main.nr @@ -0,0 +1,4 @@ + +fn main(x: Field) -> pub Field { + x % 2 +} From c500cde5d83bfddb07d652f79844a41d2096fa8e Mon Sep 17 00:00:00 2001 From: guipublic Date: Mon, 9 Oct 2023 09:31:28 +0000 Subject: [PATCH 3/5] fix test case --- .../execution_success/arithmetic_binary_operations/src/main.nr | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/tooling/nargo_cli/tests/execution_success/arithmetic_binary_operations/src/main.nr b/tooling/nargo_cli/tests/execution_success/arithmetic_binary_operations/src/main.nr index 201353393a6..78c91818345 100644 --- a/tooling/nargo_cli/tests/execution_success/arithmetic_binary_operations/src/main.nr +++ b/tooling/nargo_cli/tests/execution_success/arithmetic_binary_operations/src/main.nr @@ -4,8 +4,7 @@ // Binary addition, multiplication, division, constant modulo // x = 3, y = 4, z = 5 fn main(x : Field, y : Field, z : Field) -> pub Field { - //constant modulo - assert(x % 2 == 1); + //cast assert(y as u1 == 0); let a = x + x; // 3 + 3 = 6 From 7ed3df24bc62a9dfc3bd5a1750c9144970617427 Mon Sep 17 00:00:00 2001 From: guipublic Date: Mon, 9 Oct 2023 14:05:01 +0000 Subject: [PATCH 4/5] add field attribute --- Cargo.lock | 3 +++ acvm-repo/acir_field/Cargo.toml | 1 + acvm-repo/acir_field/src/lib.rs | 26 ++++++++++++++++++- acvm-repo/brillig/Cargo.toml | 2 ++ .../src/hir/def_collector/dc_mod.rs | 9 +++++++ compiler/noirc_frontend/src/lexer/token.rs | 19 ++++++++++++-- .../field_attribute/Nargo.toml | 7 +++++ .../field_attribute/Prover.toml | 1 + .../field_attribute/src/main.nr | 19 ++++++++++++++ 9 files changed, 84 insertions(+), 3 deletions(-) create mode 100644 tooling/nargo_cli/tests/execution_success/field_attribute/Nargo.toml create mode 100644 tooling/nargo_cli/tests/execution_success/field_attribute/Prover.toml create mode 100644 tooling/nargo_cli/tests/execution_success/field_attribute/src/main.nr diff --git a/Cargo.lock b/Cargo.lock index 87314665107..390b38b0f4f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -30,6 +30,7 @@ dependencies = [ "cfg-if", "hex", "num-bigint", + "num-traits", "serde", ] @@ -573,6 +574,8 @@ name = "brillig" version = "0.28.0" dependencies = [ "acir_field", + "num-bigint", + "num-traits", "serde", ] diff --git a/acvm-repo/acir_field/Cargo.toml b/acvm-repo/acir_field/Cargo.toml index 7d059e9e4be..492d7f81ad6 100644 --- a/acvm-repo/acir_field/Cargo.toml +++ b/acvm-repo/acir_field/Cargo.toml @@ -16,6 +16,7 @@ repository.workspace = true hex.workspace = true num-bigint.workspace = true serde.workspace = true +num-traits = "0.2" ark-bn254 = { version = "^0.4.0", optional = true, default-features = false, features = [ "curve", diff --git a/acvm-repo/acir_field/src/lib.rs b/acvm-repo/acir_field/src/lib.rs index 6d4547868cc..9dcfcc50ac2 100644 --- a/acvm-repo/acir_field/src/lib.rs +++ b/acvm-repo/acir_field/src/lib.rs @@ -3,6 +3,9 @@ #![warn(clippy::semicolon_if_nothing_returned)] #![cfg_attr(not(test), warn(unused_crate_dependencies, unused_extern_crates))] +use num_bigint::BigUint; +use num_traits::Num; + cfg_if::cfg_if! { if #[cfg(feature = "bn254")] { mod generic_ark; @@ -18,12 +21,33 @@ cfg_if::cfg_if! { } } -#[derive(Debug)] +#[derive(Debug, PartialEq, Eq)] pub enum FieldOptions { BN254, BLS12_381, } +impl FieldOptions { + pub fn to_string(&self) -> &str { + match self { + FieldOptions::BN254 => "bn254", + FieldOptions::BLS12_381 => "bls12_381", + } + } + + pub fn is_native_field(str: &str) -> bool { + let big_num = if let Some(hex) = str.strip_prefix("0x") { + BigUint::from_str_radix(hex, 16) + } else { + BigUint::from_str_radix(str, 10) + }; + if big_num.is_err() { + CHOSEN_FIELD.to_string() == str + } else { + big_num.unwrap() == FieldElement::modulus() + } + } +} // This is needed because features are additive through the dependency graph; if a dependency turns on the bn254, then it // will be turned on in all crates that depend on it #[macro_export] diff --git a/acvm-repo/brillig/Cargo.toml b/acvm-repo/brillig/Cargo.toml index c0f230ba55b..a8b03efbf66 100644 --- a/acvm-repo/brillig/Cargo.toml +++ b/acvm-repo/brillig/Cargo.toml @@ -15,6 +15,8 @@ repository.workspace = true [dependencies] acir_field.workspace = true serde.workspace = true +num-bigint.workspace = true +num-traits.workspace = true [features] default = ["bn254"] diff --git a/compiler/noirc_frontend/src/hir/def_collector/dc_mod.rs b/compiler/noirc_frontend/src/hir/def_collector/dc_mod.rs index dc99546f798..68a82b481f4 100644 --- a/compiler/noirc_frontend/src/hir/def_collector/dc_mod.rs +++ b/compiler/noirc_frontend/src/hir/def_collector/dc_mod.rs @@ -1,5 +1,6 @@ use std::vec; +use acvm::acir::acir_field::FieldOptions; use fm::FileId; use noirc_errors::Location; @@ -8,6 +9,7 @@ use crate::{ hir::def_collector::dc_crate::{UnresolvedStruct, UnresolvedTrait}, node_interner::{TraitId, TypeAliasId}, parser::{SortedModule, SortedSubModule}, + token::{FunctionAttribute, SecondaryAttribute}, FunctionDefinition, Ident, LetStatement, NoirFunction, NoirStruct, NoirTrait, NoirTraitImpl, NoirTypeAlias, TraitImplItem, TraitItem, TypeImpl, }; @@ -202,6 +204,13 @@ impl<'a> ModCollector<'a> { let module = ModuleId { krate, local_id: self.module_id }; for function in functions { + // check if optional field attribute is compatible with native field + if let Some(field) = function.attributes().get_field_attribute() { + if !FieldOptions::is_native_field(&field) { + continue; + } + } + let name = function.name_ident().clone(); let func_id = context.def_interner.push_empty_fn(); diff --git a/compiler/noirc_frontend/src/lexer/token.rs b/compiler/noirc_frontend/src/lexer/token.rs index ad81b163801..db8ba1dbbbc 100644 --- a/compiler/noirc_frontend/src/lexer/token.rs +++ b/compiler/noirc_frontend/src/lexer/token.rs @@ -1,4 +1,4 @@ -use acvm::FieldElement; +use acvm::{acir::acir_field::FieldOptions, FieldElement}; use noirc_errors::{Position, Span, Spanned}; use std::{fmt, iter::Map, vec::IntoIter}; @@ -395,6 +395,15 @@ impl Attributes { _ => None, }) } + + pub fn get_field_attribute(&self) -> Option { + for secondary in &self.secondary { + if let SecondaryAttribute::Field(field) = secondary { + return Some(field.to_lowercase()); + } + } + None + } } /// An Attribute can be either a Primary Attribute or a Secondary Attribute @@ -466,6 +475,10 @@ impl Attribute { None => return Err(malformed_scope), } } + ["field", name] => { + validate(name)?; + Attribute::Secondary(SecondaryAttribute::Field(name.to_string())) + } // Secondary attributes ["deprecated"] => Attribute::Secondary(SecondaryAttribute::Deprecated(None)), ["contract_library_method"] => { @@ -550,6 +563,7 @@ pub enum SecondaryAttribute { // the entry point. ContractLibraryMethod, Event, + Field(String), Custom(String), } @@ -563,6 +577,7 @@ impl fmt::Display for SecondaryAttribute { SecondaryAttribute::Custom(ref k) => write!(f, "#[{k}]"), SecondaryAttribute::ContractLibraryMethod => write!(f, "#[contract_library_method]"), SecondaryAttribute::Event => write!(f, "#[event]"), + SecondaryAttribute::Field(ref k) => write!(f, "#[field({k})]"), } } } @@ -583,7 +598,7 @@ impl AsRef for SecondaryAttribute { match self { SecondaryAttribute::Deprecated(Some(string)) => string, SecondaryAttribute::Deprecated(None) => "", - SecondaryAttribute::Custom(string) => string, + SecondaryAttribute::Custom(string) | SecondaryAttribute::Field(string) => string, SecondaryAttribute::ContractLibraryMethod => "", SecondaryAttribute::Event => "", } diff --git a/tooling/nargo_cli/tests/execution_success/field_attribute/Nargo.toml b/tooling/nargo_cli/tests/execution_success/field_attribute/Nargo.toml new file mode 100644 index 00000000000..f625d7e41f2 --- /dev/null +++ b/tooling/nargo_cli/tests/execution_success/field_attribute/Nargo.toml @@ -0,0 +1,7 @@ +[package] +name = "field_attribute" +type = "bin" +authors = [""] +compiler_version = "0.1" + +[dependencies] diff --git a/tooling/nargo_cli/tests/execution_success/field_attribute/Prover.toml b/tooling/nargo_cli/tests/execution_success/field_attribute/Prover.toml new file mode 100644 index 00000000000..07890234a19 --- /dev/null +++ b/tooling/nargo_cli/tests/execution_success/field_attribute/Prover.toml @@ -0,0 +1 @@ +x = "3" diff --git a/tooling/nargo_cli/tests/execution_success/field_attribute/src/main.nr b/tooling/nargo_cli/tests/execution_success/field_attribute/src/main.nr new file mode 100644 index 00000000000..5c213bb285b --- /dev/null +++ b/tooling/nargo_cli/tests/execution_success/field_attribute/src/main.nr @@ -0,0 +1,19 @@ +// Test integer addition: 3 + 4 = 7 +fn main(mut x: u32) { + assert(x> foo()); +} + +#[field(bn254)] +fn foo() -> u32 { + 1 +} + +#[field(23)] +fn foo() -> u32 { + 2 +} + +#[field(bls12_381)] +fn foo() -> u32 { + 3 +} \ No newline at end of file From 55e4b2a5b5c754bb9f7966fd2a4455cd17f8a1fd Mon Sep 17 00:00:00 2001 From: guipublic Date: Mon, 9 Oct 2023 14:18:47 +0000 Subject: [PATCH 5/5] Revert "add field attribute" This reverts commit 7ed3df24bc62a9dfc3bd5a1750c9144970617427. --- Cargo.lock | 3 --- acvm-repo/acir_field/Cargo.toml | 1 - acvm-repo/acir_field/src/lib.rs | 26 +------------------ acvm-repo/brillig/Cargo.toml | 2 -- .../src/hir/def_collector/dc_mod.rs | 9 ------- compiler/noirc_frontend/src/lexer/token.rs | 19 ++------------ .../field_attribute/Nargo.toml | 7 ----- .../field_attribute/Prover.toml | 1 - .../field_attribute/src/main.nr | 19 -------------- 9 files changed, 3 insertions(+), 84 deletions(-) delete mode 100644 tooling/nargo_cli/tests/execution_success/field_attribute/Nargo.toml delete mode 100644 tooling/nargo_cli/tests/execution_success/field_attribute/Prover.toml delete mode 100644 tooling/nargo_cli/tests/execution_success/field_attribute/src/main.nr diff --git a/Cargo.lock b/Cargo.lock index 390b38b0f4f..87314665107 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -30,7 +30,6 @@ dependencies = [ "cfg-if", "hex", "num-bigint", - "num-traits", "serde", ] @@ -574,8 +573,6 @@ name = "brillig" version = "0.28.0" dependencies = [ "acir_field", - "num-bigint", - "num-traits", "serde", ] diff --git a/acvm-repo/acir_field/Cargo.toml b/acvm-repo/acir_field/Cargo.toml index 492d7f81ad6..7d059e9e4be 100644 --- a/acvm-repo/acir_field/Cargo.toml +++ b/acvm-repo/acir_field/Cargo.toml @@ -16,7 +16,6 @@ repository.workspace = true hex.workspace = true num-bigint.workspace = true serde.workspace = true -num-traits = "0.2" ark-bn254 = { version = "^0.4.0", optional = true, default-features = false, features = [ "curve", diff --git a/acvm-repo/acir_field/src/lib.rs b/acvm-repo/acir_field/src/lib.rs index 9dcfcc50ac2..6d4547868cc 100644 --- a/acvm-repo/acir_field/src/lib.rs +++ b/acvm-repo/acir_field/src/lib.rs @@ -3,9 +3,6 @@ #![warn(clippy::semicolon_if_nothing_returned)] #![cfg_attr(not(test), warn(unused_crate_dependencies, unused_extern_crates))] -use num_bigint::BigUint; -use num_traits::Num; - cfg_if::cfg_if! { if #[cfg(feature = "bn254")] { mod generic_ark; @@ -21,33 +18,12 @@ cfg_if::cfg_if! { } } -#[derive(Debug, PartialEq, Eq)] +#[derive(Debug)] pub enum FieldOptions { BN254, BLS12_381, } -impl FieldOptions { - pub fn to_string(&self) -> &str { - match self { - FieldOptions::BN254 => "bn254", - FieldOptions::BLS12_381 => "bls12_381", - } - } - - pub fn is_native_field(str: &str) -> bool { - let big_num = if let Some(hex) = str.strip_prefix("0x") { - BigUint::from_str_radix(hex, 16) - } else { - BigUint::from_str_radix(str, 10) - }; - if big_num.is_err() { - CHOSEN_FIELD.to_string() == str - } else { - big_num.unwrap() == FieldElement::modulus() - } - } -} // This is needed because features are additive through the dependency graph; if a dependency turns on the bn254, then it // will be turned on in all crates that depend on it #[macro_export] diff --git a/acvm-repo/brillig/Cargo.toml b/acvm-repo/brillig/Cargo.toml index a8b03efbf66..c0f230ba55b 100644 --- a/acvm-repo/brillig/Cargo.toml +++ b/acvm-repo/brillig/Cargo.toml @@ -15,8 +15,6 @@ repository.workspace = true [dependencies] acir_field.workspace = true serde.workspace = true -num-bigint.workspace = true -num-traits.workspace = true [features] default = ["bn254"] diff --git a/compiler/noirc_frontend/src/hir/def_collector/dc_mod.rs b/compiler/noirc_frontend/src/hir/def_collector/dc_mod.rs index 68a82b481f4..dc99546f798 100644 --- a/compiler/noirc_frontend/src/hir/def_collector/dc_mod.rs +++ b/compiler/noirc_frontend/src/hir/def_collector/dc_mod.rs @@ -1,6 +1,5 @@ use std::vec; -use acvm::acir::acir_field::FieldOptions; use fm::FileId; use noirc_errors::Location; @@ -9,7 +8,6 @@ use crate::{ hir::def_collector::dc_crate::{UnresolvedStruct, UnresolvedTrait}, node_interner::{TraitId, TypeAliasId}, parser::{SortedModule, SortedSubModule}, - token::{FunctionAttribute, SecondaryAttribute}, FunctionDefinition, Ident, LetStatement, NoirFunction, NoirStruct, NoirTrait, NoirTraitImpl, NoirTypeAlias, TraitImplItem, TraitItem, TypeImpl, }; @@ -204,13 +202,6 @@ impl<'a> ModCollector<'a> { let module = ModuleId { krate, local_id: self.module_id }; for function in functions { - // check if optional field attribute is compatible with native field - if let Some(field) = function.attributes().get_field_attribute() { - if !FieldOptions::is_native_field(&field) { - continue; - } - } - let name = function.name_ident().clone(); let func_id = context.def_interner.push_empty_fn(); diff --git a/compiler/noirc_frontend/src/lexer/token.rs b/compiler/noirc_frontend/src/lexer/token.rs index db8ba1dbbbc..ad81b163801 100644 --- a/compiler/noirc_frontend/src/lexer/token.rs +++ b/compiler/noirc_frontend/src/lexer/token.rs @@ -1,4 +1,4 @@ -use acvm::{acir::acir_field::FieldOptions, FieldElement}; +use acvm::FieldElement; use noirc_errors::{Position, Span, Spanned}; use std::{fmt, iter::Map, vec::IntoIter}; @@ -395,15 +395,6 @@ impl Attributes { _ => None, }) } - - pub fn get_field_attribute(&self) -> Option { - for secondary in &self.secondary { - if let SecondaryAttribute::Field(field) = secondary { - return Some(field.to_lowercase()); - } - } - None - } } /// An Attribute can be either a Primary Attribute or a Secondary Attribute @@ -475,10 +466,6 @@ impl Attribute { None => return Err(malformed_scope), } } - ["field", name] => { - validate(name)?; - Attribute::Secondary(SecondaryAttribute::Field(name.to_string())) - } // Secondary attributes ["deprecated"] => Attribute::Secondary(SecondaryAttribute::Deprecated(None)), ["contract_library_method"] => { @@ -563,7 +550,6 @@ pub enum SecondaryAttribute { // the entry point. ContractLibraryMethod, Event, - Field(String), Custom(String), } @@ -577,7 +563,6 @@ impl fmt::Display for SecondaryAttribute { SecondaryAttribute::Custom(ref k) => write!(f, "#[{k}]"), SecondaryAttribute::ContractLibraryMethod => write!(f, "#[contract_library_method]"), SecondaryAttribute::Event => write!(f, "#[event]"), - SecondaryAttribute::Field(ref k) => write!(f, "#[field({k})]"), } } } @@ -598,7 +583,7 @@ impl AsRef for SecondaryAttribute { match self { SecondaryAttribute::Deprecated(Some(string)) => string, SecondaryAttribute::Deprecated(None) => "", - SecondaryAttribute::Custom(string) | SecondaryAttribute::Field(string) => string, + SecondaryAttribute::Custom(string) => string, SecondaryAttribute::ContractLibraryMethod => "", SecondaryAttribute::Event => "", } diff --git a/tooling/nargo_cli/tests/execution_success/field_attribute/Nargo.toml b/tooling/nargo_cli/tests/execution_success/field_attribute/Nargo.toml deleted file mode 100644 index f625d7e41f2..00000000000 --- a/tooling/nargo_cli/tests/execution_success/field_attribute/Nargo.toml +++ /dev/null @@ -1,7 +0,0 @@ -[package] -name = "field_attribute" -type = "bin" -authors = [""] -compiler_version = "0.1" - -[dependencies] diff --git a/tooling/nargo_cli/tests/execution_success/field_attribute/Prover.toml b/tooling/nargo_cli/tests/execution_success/field_attribute/Prover.toml deleted file mode 100644 index 07890234a19..00000000000 --- a/tooling/nargo_cli/tests/execution_success/field_attribute/Prover.toml +++ /dev/null @@ -1 +0,0 @@ -x = "3" diff --git a/tooling/nargo_cli/tests/execution_success/field_attribute/src/main.nr b/tooling/nargo_cli/tests/execution_success/field_attribute/src/main.nr deleted file mode 100644 index 5c213bb285b..00000000000 --- a/tooling/nargo_cli/tests/execution_success/field_attribute/src/main.nr +++ /dev/null @@ -1,19 +0,0 @@ -// Test integer addition: 3 + 4 = 7 -fn main(mut x: u32) { - assert(x> foo()); -} - -#[field(bn254)] -fn foo() -> u32 { - 1 -} - -#[field(23)] -fn foo() -> u32 { - 2 -} - -#[field(bls12_381)] -fn foo() -> u32 { - 3 -} \ No newline at end of file