mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
scanner: make Scanner.peek_token more robust (p.peek_token(-999999) will return an EOF token, instead of garbage data)
This commit is contained in:
parent
50b73abc62
commit
fdbd40d806
@ -605,7 +605,7 @@ pub fn (mut s Scanner) scan() token.Token {
|
||||
[direct_array_access; inline]
|
||||
pub fn (s &Scanner) peek_token(n int) token.Token {
|
||||
idx := s.tidx + n
|
||||
if idx >= s.all_tokens.len {
|
||||
if idx >= s.all_tokens.len || idx < 0 {
|
||||
return s.new_eof_token()
|
||||
}
|
||||
t := s.all_tokens[idx]
|
||||
|
Loading…
Reference in New Issue
Block a user