From 0dc7a57e1fb6064f14d1d9419457cd347af2a00f Mon Sep 17 00:00:00 2001 From: Henrixounez <30901439+Henrixounez@users.noreply.github.com> Date: Tue, 28 Apr 2020 18:57:16 +0200 Subject: [PATCH] scanner: prevent panic with string starting on first character --- vlib/v/scanner/scanner.v | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vlib/v/scanner/scanner.v b/vlib/v/scanner/scanner.v index 44c72efdae..7fb12f60d5 100644 --- a/vlib/v/scanner/scanner.v +++ b/vlib/v/scanner/scanner.v @@ -833,7 +833,7 @@ fn (s &Scanner) count_symbol_before(p int, sym byte) int { fn (s mut Scanner) ident_string() string { q := s.text[s.pos] is_quote := q == single_quote || q == double_quote - is_raw := is_quote && s.text[s.pos - 1] == `r` + is_raw := is_quote && s.pos > 0 && s.text[s.pos - 1] == `r` if is_quote && !s.is_inside_string { s.quote = q }