parser: fix weird minus after comment parse error in arrays (#8912)

pull/8926/head
Lukas Neubert 2021-02-23 08:51:00 +01:00 committed by GitHub
parent fcc2094719
commit 51125541c7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 0 deletions

View File

@ -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]
}

View File

@ -45,6 +45,7 @@ pub fn (mut p Parser) expr(precedence int) ast.Expr {
}
.comment {
node = p.comment()
return node
}
.dot {
// .enum_val