diff --git a/vlib/compiler/scanner.v b/vlib/compiler/scanner.v index 1fd24060fb..073771d912 100644 --- a/vlib/compiler/scanner.v +++ b/vlib/compiler/scanner.v @@ -354,7 +354,7 @@ fn (s mut Scanner) scan() ScanRes { } mut prefix_zero_num := start_pos - s.pos // how many prefix zeros should be jumped // for 0b, 0o, 0x the heading zero shouldn't be jumped - if c == `0` && start_pos < s.text.len && !s.text[start_pos].is_digit() { + if start_pos == s.text.len || (c == `0` && !s.text[start_pos].is_digit()) { prefix_zero_num-- } s.pos += prefix_zero_num // jump these zeros diff --git a/vlib/v/scanner/scanner.v b/vlib/v/scanner/scanner.v index 03ca391350..ac978eaf93 100644 --- a/vlib/v/scanner/scanner.v +++ b/vlib/v/scanner/scanner.v @@ -348,7 +348,7 @@ pub fn (s mut Scanner) scan() token.Token { } mut prefix_zero_num := start_pos - s.pos // how many prefix zeros should be jumped // for 0b, 0o, 0x the heading zero shouldn't be jumped - if c == `0` && start_pos < s.text.len && !s.text[start_pos].is_digit() { + if start_pos == s.text.len || (c == `0` && !s.text[start_pos].is_digit()) { prefix_zero_num-- } s.pos += prefix_zero_num // jump these zeros