diff --git a/vlib/v/fmt/tests/empty_lines_keep.vv b/vlib/v/fmt/tests/empty_lines_keep.vv index 2e4a778b53..48da308d0a 100644 --- a/vlib/v/fmt/tests/empty_lines_keep.vv +++ b/vlib/v/fmt/tests/empty_lines_keep.vv @@ -40,6 +40,9 @@ fn keep_single_empty_line() { } f := 0 + arr << MyStruct{} + + arr2 := [1, 2] } fn prevent_empty_line_after_multi_line_statements() { diff --git a/vlib/v/parser/struct.v b/vlib/v/parser/struct.v index 73428ead4d..5120c7169a 100644 --- a/vlib/v/parser/struct.v +++ b/vlib/v/parser/struct.v @@ -407,7 +407,6 @@ fn (mut p Parser) struct_init(short_syntax bool) ast.StructInit { } } } - last_pos := p.tok.position() if !short_syntax { p.check(.rcbr) } @@ -419,7 +418,7 @@ fn (mut p Parser) struct_init(short_syntax bool) ast.StructInit { update_expr: update_expr update_expr_comments: update_expr_comments has_update_expr: has_update_expr - pos: first_pos.extend_with_last_line(last_pos, p.tok.line_nr) + pos: first_pos.extend(p.prev_tok.position()) is_short: no_keys pre_comments: pre_comments }