From b789764f48ce52a9e5d2fccec664ae2a2aea288f Mon Sep 17 00:00:00 2001 From: f01dab1e Date: Tue, 31 Oct 2023 11:36:19 +0000 Subject: [PATCH 1/2] chore: attribute with speed marks --- 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..69824dd2d52 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_speed_marks() { + let input = r#"#[test(should_fail_with = "this can't compile")]"#; + 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: "this can't compile".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(()); From 3dbf281744b44e357aada6df79986ff177a28516 Mon Sep 17 00:00:00 2001 From: f01dab1e Date: Wed, 1 Nov 2023 16:58:07 +0000 Subject: [PATCH 2/2] fix message --- compiler/noirc_frontend/src/lexer/lexer.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/compiler/noirc_frontend/src/lexer/lexer.rs b/compiler/noirc_frontend/src/lexer/lexer.rs index 69824dd2d52..5f35e60dea7 100644 --- a/compiler/noirc_frontend/src/lexer/lexer.rs +++ b/compiler/noirc_frontend/src/lexer/lexer.rs @@ -542,15 +542,15 @@ mod tests { } #[test] - fn test_attribute_with_speed_marks() { - let input = r#"#[test(should_fail_with = "this can't compile")]"#; + 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: "this can't compile".to_owned().into() } + TestScope::ShouldFailWith { reason: "the eagle's feathers".to_owned().into() } ))) ); }