chore: re-add empty line handling by @KtorZ
Co-authored-by: KtorZ
This commit is contained in:
parent
41a08e4a06
commit
3fc9c8e0db
|
@ -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);
|
||||
|
|
|
@ -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) == []
|
||||
}
|
||||
"#});
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue