scanner: fix eof token position (#9432)

pull/9433/head
Ned Palacios 2021-03-23 15:51:09 +08:00 committed by GitHub
parent aa4e22c287
commit b9cbb4f177
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 6 additions and 2 deletions

View File

@ -0,0 +1,3 @@
vlib/v/parser/tests/fn_decl_unexpected_eof.vv:1:12: error: unexpected eof, expecting `}`
1 | fn main() {
| ^

View File

@ -0,0 +1 @@
fn main() {

View File

@ -191,7 +191,7 @@ fn (s &Scanner) new_eof_token() token.Token {
kind: .eof kind: .eof
lit: '' lit: ''
line_nr: s.line_nr + 1 line_nr: s.line_nr + 1
col: 1 col: s.current_column()
pos: s.pos pos: s.pos
len: 1 len: 1
tidx: s.tidx tidx: s.tidx
@ -576,7 +576,7 @@ pub fn (mut s Scanner) buffer_scan() token.Token {
} }
return s.all_tokens[cidx] return s.all_tokens[cidx]
} }
return s.new_token(.eof, '', 1) return s.new_eof_token()
} }
[inline] [inline]