From 3d76fd274dc703fc84df34b8533e4749fdf75568 Mon Sep 17 00:00:00 2001 From: kek kek kek Date: Thu, 2 Nov 2023 09:35:49 -0700 Subject: [PATCH] chore: Allow apostrophes in attributes (#3374) --- compiler/noirc_frontend/src/lexer/lexer.rs | 14 ++++++++++++++ compiler/noirc_frontend/src/lexer/token.rs | 1 + 2 files changed, 15 insertions(+) diff --git a/compiler/noirc_frontend/src/lexer/lexer.rs b/compiler/noirc_frontend/src/lexer/lexer.rs index 4a5ea56d8bc..5f35e60dea7 100644 --- a/compiler/noirc_frontend/src/lexer/lexer.rs +++ b/compiler/noirc_frontend/src/lexer/lexer.rs @@ -541,6 +541,20 @@ mod tests { ); } + #[test] + fn test_attribute_with_apostrophe() { + let input = r#"#[test(should_fail_with = "the eagle's feathers")]"#; + let mut lexer = Lexer::new(input); + + let token = lexer.next_token().unwrap().token().clone(); + assert_eq!( + token, + Token::Attribute(Attribute::Function(FunctionAttribute::Test( + TestScope::ShouldFailWith { reason: "the eagle's feathers".to_owned().into() } + ))) + ); + } + #[test] fn deprecated_attribute_with_note() { let input = r#"#[deprecated("hello")]"#; diff --git a/compiler/noirc_frontend/src/lexer/token.rs b/compiler/noirc_frontend/src/lexer/token.rs index fe3e9476318..28e17b2b88d 100644 --- a/compiler/noirc_frontend/src/lexer/token.rs +++ b/compiler/noirc_frontend/src/lexer/token.rs @@ -462,6 +462,7 @@ impl Attribute { || ch == '=' || ch == '"' || ch == ' ' + || ch == '\'' }) .then_some(());