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