From 79c2bca401f822e23c8cf8d15e66e97fbe0bc0f8 Mon Sep 17 00:00:00 2001 From: Enzo Date: Tue, 7 Sep 2021 19:46:56 +0200 Subject: [PATCH] v.scanner: fix error messages with unexpected token `?` (#11428) --- vlib/v/parser/tests/unexpected_token.out | 5 +++++ vlib/v/parser/tests/unexpected_token.vv | 3 +++ vlib/v/scanner/scanner.v | 2 +- 3 files changed, 9 insertions(+), 1 deletion(-) create mode 100644 vlib/v/parser/tests/unexpected_token.out create mode 100644 vlib/v/parser/tests/unexpected_token.vv diff --git a/vlib/v/parser/tests/unexpected_token.out b/vlib/v/parser/tests/unexpected_token.out new file mode 100644 index 0000000000..16e0545509 --- /dev/null +++ b/vlib/v/parser/tests/unexpected_token.out @@ -0,0 +1,5 @@ +vlib/v/parser/tests/unexpected_token.vv:2:10: error: unexpected token `?` + 1 | fn main() { + 2 | println(?) + | ^ + 3 | } diff --git a/vlib/v/parser/tests/unexpected_token.vv b/vlib/v/parser/tests/unexpected_token.vv new file mode 100644 index 0000000000..79993c6d3e --- /dev/null +++ b/vlib/v/parser/tests/unexpected_token.vv @@ -0,0 +1,3 @@ +fn main() { + println(?) +} diff --git a/vlib/v/scanner/scanner.v b/vlib/v/scanner/scanner.v index 832ef82559..583cb8b966 100644 --- a/vlib/v/scanner/scanner.v +++ b/vlib/v/scanner/scanner.v @@ -771,7 +771,7 @@ fn (mut s Scanner) text_scan() token.Token { return s.new_token(.mod, '', 1) } `?` { - return s.new_token(.question, '', 1) + return s.new_token(.question, '?', 1) } scanner.single_quote, scanner.double_quote { start_line := s.line_nr