From efd1597d843463cc89a7a8d44c8d2390e480a577 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20D=C3=A4schle?= Date: Fri, 13 May 2022 07:30:10 +0200 Subject: [PATCH] parser: fix dollar (closes #14292) (#14378) --- vlib/v/parser/parser.v | 3 +++ vlib/v/parser/tests/dollar_err.out | 3 +++ vlib/v/parser/tests/dollar_err.vv | 1 + 3 files changed, 7 insertions(+) create mode 100644 vlib/v/parser/tests/dollar_err.out create mode 100644 vlib/v/parser/tests/dollar_err.vv diff --git a/vlib/v/parser/parser.v b/vlib/v/parser/parser.v index 7e022cab4d..55000ac7c4 100644 --- a/vlib/v/parser/parser.v +++ b/vlib/v/parser/parser.v @@ -663,6 +663,9 @@ pub fn (mut p Parser) top_stmt() ast.Stmt { return p.struct_decl() } .dollar { + if p.peek_tok.kind == .eof { + return p.error('unexpected eof') + } if_expr := p.if_expr(true) return ast.ExprStmt{ expr: if_expr diff --git a/vlib/v/parser/tests/dollar_err.out b/vlib/v/parser/tests/dollar_err.out new file mode 100644 index 0000000000..5355374861 --- /dev/null +++ b/vlib/v/parser/tests/dollar_err.out @@ -0,0 +1,3 @@ +vlib/v/parser/tests/dollar_err.vv:1:1: error: unexpected eof, expecting `if` + 1 | $ + | ^ \ No newline at end of file diff --git a/vlib/v/parser/tests/dollar_err.vv b/vlib/v/parser/tests/dollar_err.vv new file mode 100644 index 0000000000..857f13ad1b --- /dev/null +++ b/vlib/v/parser/tests/dollar_err.vv @@ -0,0 +1 @@ +$