parser: fix StructInitField pos, when value expr is empty (#7643)
parent
d46b930c71
commit
2946673bc2
|
@ -344,10 +344,12 @@ fn (mut p Parser) struct_init(short_syntax bool) ast.StructInit {
|
||||||
expr = p.expr(0)
|
expr = p.expr(0)
|
||||||
comments = p.eat_line_end_comments()
|
comments = p.eat_line_end_comments()
|
||||||
last_field_pos := expr.position()
|
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{
|
field_pos = token.Position{
|
||||||
line_nr: first_field_pos.line_nr
|
line_nr: first_field_pos.line_nr
|
||||||
pos: first_field_pos.pos
|
pos: first_field_pos.pos
|
||||||
len: last_field_pos.pos - first_field_pos.pos + last_field_pos.len
|
len: field_len
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
i++
|
i++
|
||||||
|
|
Loading…
Reference in New Issue