chore: re-add empty line handling by @KtorZ

Co-authored-by: KtorZ
This commit is contained in:
rvcas 2023-06-07 17:21:04 -04:00
parent 41a08e4a06
commit 3fc9c8e0db
No known key found for this signature in database
GPG Key ID: C09B64E263F7D68C
2 changed files with 41 additions and 1 deletions

View File

@ -34,7 +34,7 @@ pub fn module(
let mut previous_is_newline = false;
let tokens = tokens.into_iter().filter_map(|(token, ref span)| {
let current_is_newline = token == Token::NewLine;
let current_is_newline = token == Token::NewLine || token == Token::EmptyLine;
let result = match token {
Token::ModuleComment => {
extra.module_comments.push(*span);

View File

@ -3297,3 +3297,43 @@ fn parse_keyword_todo() {
],
)
}
#[test]
fn brackets_followed_by_parenthesis() {
fn assert_sequence(code: &str) {
let (module, _extra) = parser::module(code, ast::ModuleKind::Validator).unwrap();
assert!(
matches!(
module.definitions[..],
[ast::Definition::Test(Function {
body: expr::UntypedExpr::Sequence { .. },
..
})]
),
"{}",
code.to_string()
);
}
assert_sequence(indoc! {r#"
test foo () {
let a = []
(x |> y) == []
}
"#});
assert_sequence(indoc! {r#"
test foo () {
let a = []
(x |> y) == []
}
"#});
assert_sequence(indoc! {r#"
test foo () {
let a = []
// foo
(x |> y) == []
}
"#});
}