diff --git a/vlib/v/fmt/tests/comments_embedded_keep.vv b/vlib/v/fmt/tests/comments_embedded_keep.vv index a28f94bb39..4f8b36997b 100644 --- a/vlib/v/fmt/tests/comments_embedded_keep.vv +++ b/vlib/v/fmt/tests/comments_embedded_keep.vv @@ -14,4 +14,10 @@ fn only_comments_array() { fn array_pre_comments() { _ := [/* 2, */ 3] _ := [/* 4, */ /* 5, */ 6] + _ := [/* cmt */ -4] +} + +fn negative_num_after_comment_expr() { + // This caused a bug where the ´-´ was parsed as InfixExpr and not as part of an IntegerLiteral + _ := [1, /* cmt */ -4] } diff --git a/vlib/v/parser/pratt.v b/vlib/v/parser/pratt.v index 9dbd1e8252..0f6769b0ad 100644 --- a/vlib/v/parser/pratt.v +++ b/vlib/v/parser/pratt.v @@ -45,6 +45,7 @@ pub fn (mut p Parser) expr(precedence int) ast.Expr { } .comment { node = p.comment() + return node } .dot { // .enum_val