parser: set correct last line for struct inits (#9349)

pull/9358/head
Lukas Neubert 2021-03-17 19:46:08 +01:00 committed by GitHub
parent 0a06a83d9b
commit 49eeddcd1c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 2 deletions

View File

@ -40,6 +40,9 @@ fn keep_single_empty_line() {
}
f := 0
arr << MyStruct{}
arr2 := [1, 2]
}
fn prevent_empty_line_after_multi_line_statements() {

View File

@ -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
}