parser: fix position offset by 1 (#7099)

pull/7144/head
Daniel Däschle 2020-12-03 10:25:06 +01:00 committed by GitHub
parent 97ed2bf211
commit 558a756431
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 4 additions and 12 deletions

View File

@ -9,6 +9,6 @@ vlib/v/checker/tests/match_sumtype_multiple_types.vv:27:13: error: unknown metho
25 | Alfa, Charlie { 25 | Alfa, Charlie {
26 | assert l.char == `a` 26 | assert l.char == `a`
27 | assert l.letter() == 'a' 27 | assert l.letter() == 'a'
| ~~~~~~~~~ | ~~~~~~~~
28 | } 28 | }
29 | Bravo { 29 | Bravo {

View File

@ -50,11 +50,7 @@ pub fn (mut p Parser) call_expr(language table.Language, mod string) ast.CallExp
if p.tok.kind == .not { if p.tok.kind == .not {
p.next() p.next()
} }
pos := token.Position{ pos := first_pos.extend(last_pos)
line_nr: first_pos.line_nr
pos: first_pos.pos
len: last_pos.pos - first_pos.pos + last_pos.len
}
mut or_stmts := []ast.Stmt{} mut or_stmts := []ast.Stmt{}
mut or_pos := p.tok.position() mut or_pos := p.tok.position()
if p.tok.kind == .key_orelse { if p.tok.kind == .key_orelse {

View File

@ -1351,12 +1351,8 @@ fn (mut p Parser) dot_expr(left ast.Expr) ast.Expr {
or_kind = .propagate or_kind = .propagate
} }
// //
end_pos := p.tok.position() end_pos := p.prev_tok.position()
pos := token.Position{ pos := name_pos.extend(end_pos)
line_nr: name_pos.line_nr
pos: name_pos.pos
len: end_pos.pos - name_pos.pos
}
mcall_expr := ast.CallExpr{ mcall_expr := ast.CallExpr{
left: left left: left
name: field_name name: field_name