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

parser: fix dump removing empty lines (#18452)

This commit is contained in:
Turiiya 2023-06-16 08:45:50 +02:00 committed by GitHub
parent 5001b17336
commit 5d0af69bfd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 10 additions and 1 deletions

View File

@ -10,6 +10,8 @@ fn squash_multiple_empty_lines() {
println('b') println('b')
dump('c')
c := 0 c := 0
d := 0 d := 0

View File

@ -8,6 +8,8 @@ fn squash_multiple_empty_lines() {
println('b') println('b')
dump('c')
c := 0 c := 0

View File

@ -33,12 +33,15 @@ fn keep_single_empty_line() {
println('c') println('c')
dump('d')
d := 0 d := 0
if true { if true {
println('e') println('e')
} }
dump('f')
f := 0 f := 0
arr << MyStruct{} arr << MyStruct{}

View File

@ -328,9 +328,11 @@ fn (mut p Parser) check_expr(precedence int) !ast.Expr {
p.next() p.next()
} }
p.check(.rpar) p.check(.rpar)
mut pos := p.tok.pos()
pos.update_last_line(p.prev_tok.line_nr)
node = ast.DumpExpr{ node = ast.DumpExpr{
expr: expr expr: expr
pos: spos.extend(p.tok.pos()) pos: spos.extend(pos)
} }
} }
.key_offsetof { .key_offsetof {