1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

parser: fix StructInitField pos, when value expr is empty (#7643)

This commit is contained in:
Ned Palacios 2020-12-28 18:39:02 +08:00 committed by GitHub
parent d46b930c71
commit 2946673bc2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -344,10 +344,12 @@ fn (mut p Parser) struct_init(short_syntax bool) ast.StructInit {
expr = p.expr(0)
comments = p.eat_line_end_comments()
last_field_pos := expr.position()
field_len := if last_field_pos.len > 0 { last_field_pos.pos - first_field_pos.pos +
last_field_pos.len } else { first_field_pos.len + 1 }
field_pos = token.Position{
line_nr: first_field_pos.line_nr
pos: first_field_pos.pos
len: last_field_pos.pos - first_field_pos.pos + last_field_pos.len
len: field_len
}
}
i++