From 96da5b33c095ff5db2804e7f91a1cd0c742b620c Mon Sep 17 00:00:00 2001 From: SleepyRoy <47302112+SleepyRoy@users.noreply.github.com> Date: Tue, 25 Feb 2020 01:01:51 +0800 Subject: [PATCH] scanner: fix special case - 0 at the end --- vlib/compiler/scanner.v | 2 +- vlib/v/scanner/scanner.v | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) 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