From 02aa236f8b6679e198741e5665b3ffe3c86fed17 Mon Sep 17 00:00:00 2001 From: Ary Borenszweig Date: Tue, 11 Nov 2025 15:17:37 -0300 Subject: [PATCH] fix: disallow keywords in attributes --- .../src/parser/parser/attributes.rs | 26 +------------------ 1 file changed, 1 insertion(+), 25 deletions(-) diff --git a/compiler/noirc_frontend/src/parser/parser/attributes.rs b/compiler/noirc_frontend/src/parser/parser/attributes.rs index e49387e9470..1e07fd6dee8 100644 --- a/compiler/noirc_frontend/src/parser/parser/attributes.rs +++ b/compiler/noirc_frontend/src/parser/parser/attributes.rs @@ -143,15 +143,7 @@ impl Parser<'_> { } fn parse_non_tag_attribute(&mut self, start_location: Location) -> Attribute { - if matches!(&self.token.token(), Token::Keyword(..)) - && (self.next_is(Token::LeftParen) || self.next_is(Token::RightBracket)) - { - // This is a Meta attribute with the syntax `keyword(arg1, arg2, .., argN)` - let path = Path::from_single(self.token.to_string(), self.current_token_location); - let name = MetaAttributeName::Path(path); - self.bump(); - self.parse_meta_attribute(name, start_location) - } else if let Some(path) = self.parse_path_no_turbofish() { + if let Some(path) = self.parse_path_no_turbofish() { if let Some(ident) = path.as_ident() { if ident.as_str() == "test" { // The test attribute is the only secondary attribute that has `a = b` in its syntax @@ -764,22 +756,6 @@ mod tests { assert!(meta.arguments.is_empty()); } - #[test] - fn parses_meta_attribute_single_identifier_as_keyword() { - let src = "#[dep]"; - let mut parser = Parser::for_str_with_dummy_file(src); - let (attribute, _span) = parser.parse_attribute().unwrap(); - expect_no_errors(&parser.errors); - let Attribute::Secondary(attribute) = attribute else { - panic!("Expected secondary attribute"); - }; - let SecondaryAttributeKind::Meta(meta) = attribute.kind else { - panic!("Expected meta attribute"); - }; - assert_eq!(meta.name.to_string(), "dep"); - assert!(meta.arguments.is_empty()); - } - #[test] fn parses_meta_attribute_single_identifier_with_arguments() { let src = "#[foo(1, 2, 3)]";