From 0f1ed1ca09bcac34899be7c4e91cbe6e340471d0 Mon Sep 17 00:00:00 2001 From: Henrixounez <30901439+Henrixounez@users.noreply.github.com> Date: Thu, 1 Oct 2020 15:40:59 +0200 Subject: [PATCH] scanner: add an error for unfinished string literals (#6519) --- vlib/v/checker/tests/unfinished_string.out | 2 ++ vlib/v/checker/tests/unfinished_string.vv | 1 + vlib/v/scanner/scanner.v | 2 +- 3 files changed, 4 insertions(+), 1 deletion(-) create mode 100644 vlib/v/checker/tests/unfinished_string.out create mode 100644 vlib/v/checker/tests/unfinished_string.vv diff --git a/vlib/v/checker/tests/unfinished_string.out b/vlib/v/checker/tests/unfinished_string.out new file mode 100644 index 0000000000..c42f70aea2 --- /dev/null +++ b/vlib/v/checker/tests/unfinished_string.out @@ -0,0 +1,2 @@ +vlib/v/checker/tests/unfinished_string.vv:2:1: error: unfinished string literal + 1 | a := ' diff --git a/vlib/v/checker/tests/unfinished_string.vv b/vlib/v/checker/tests/unfinished_string.vv new file mode 100644 index 0000000000..e6374fb3ab --- /dev/null +++ b/vlib/v/checker/tests/unfinished_string.vv @@ -0,0 +1 @@ +a := ' diff --git a/vlib/v/scanner/scanner.v b/vlib/v/scanner/scanner.v index 90b90a220c..1a49d5ee31 100644 --- a/vlib/v/scanner/scanner.v +++ b/vlib/v/scanner/scanner.v @@ -1193,7 +1193,7 @@ fn (mut s Scanner) ident_string() string { for { s.pos++ if s.pos >= s.text.len { - break + s.error('unfinished string literal') } c := s.text[s.pos] prevc := s.text[s.pos - 1]