1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

parser, fmt: prevent error with comment after expr inside match (#9995)

This commit is contained in:
Lukas Neubert 2021-05-04 17:26:10 +02:00 committed by GitHub
parent 6745a7d725
commit 9e717e02c9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 1 deletions

View File

@ -37,6 +37,12 @@ fn main() {
////// //////
// / // /
// 123 // 123
match 0 {
0 {
0 // comment after an expression inside match
}
else {}
}
} }
fn assign_comments() { fn assign_comments() {

View File

@ -1694,7 +1694,7 @@ fn (mut p Parser) parse_multi_expr(is_top_level bool) ast.Stmt {
// TODO remove translated // TODO remove translated
if p.tok.kind in [.assign, .decl_assign] || p.tok.kind.is_assign() { if p.tok.kind in [.assign, .decl_assign] || p.tok.kind.is_assign() {
return p.partial_assign_stmt(left, left_comments) return p.partial_assign_stmt(left, left_comments)
} else if !p.pref.translated } else if !p.pref.translated && !p.pref.is_fmt
&& tok.kind !in [.key_if, .key_match, .key_lock, .key_rlock, .key_select] { && tok.kind !in [.key_if, .key_match, .key_lock, .key_rlock, .key_select] {
for node in left { for node in left {
if node !is ast.CallExpr && (is_top_level || p.tok.kind != .rcbr) if node !is ast.CallExpr && (is_top_level || p.tok.kind != .rcbr)