From 519028e263f3aa408b50af4a7f5b650f8aebf378 Mon Sep 17 00:00:00 2001 From: Shiqing Date: Fri, 30 Aug 2019 00:54:21 +0800 Subject: [PATCH] Fix incorrect string open/close check in REPL --- compiler/repl.v | 2 +- compiler/tests/repl/naked_strings.repl | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/compiler/repl.v b/compiler/repl.v index 814801600c..776cb0e9ed 100644 --- a/compiler/repl.v +++ b/compiler/repl.v @@ -22,7 +22,7 @@ fn (r mut Repl) checks(line string) bool { was_indent := r.indent > 0 for i := 0; i < line.len; i++ { - if line[i] == `\'` && (i != 0 && line[i - 1] != `\\`) { + if line[i] == `\'` && (i == 0 || line[i - 1] != `\\`) { in_string = !in_string } if line[i] == `{` && !in_string { diff --git a/compiler/tests/repl/naked_strings.repl b/compiler/tests/repl/naked_strings.repl index 3769ccc964..ba6fc474c7 100644 --- a/compiler/tests/repl/naked_strings.repl +++ b/compiler/tests/repl/naked_strings.repl @@ -1,5 +1,9 @@ 'abc' 'abc'+'xyz' +'{' +'}' ===output=== abc abcxyz +{ +}