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 @@ +$