scanner: prevent panic with string starting on first character

pull/4644/head
Henrixounez 2020-04-28 18:57:16 +02:00 committed by GitHub
parent 8c526ad05b
commit 0dc7a57e1f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 1 additions and 1 deletions

View File

@ -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
}