From 63ec3c0486adbb7f4c5306157cecab3f2b6a4215 Mon Sep 17 00:00:00 2001 From: Alexander Medvednikov Date: Sat, 7 Dec 2019 18:19:48 +0300 Subject: [PATCH] fix a wrong "0 character in a string literal" error --- vlib/compiler/scanner.v | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/vlib/compiler/scanner.v b/vlib/compiler/scanner.v index 052a46ad48..91d171cd4c 100644 --- a/vlib/compiler/scanner.v +++ b/vlib/compiler/scanner.v @@ -697,8 +697,12 @@ fn (s mut Scanner) ident_string() string { s.inc_line_number() } // Don't allow \0 - if c == `0` && s.pos > 2 && s.text[s.pos - 1] == slash { - s.error('0 character in a string literal') + if c == `0` && s.pos > 2 && s.text[s.pos - 1] == slash { + if s.pos < s.text.len - 1 && s.text[s.pos+1].is_digit() { + + } else { + s.error('0 character in a string literal') + } } // Don't allow \x00 if c == `0` && s.pos > 5 && s.expect('\\x0', s.pos - 3) {