mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
parser: fix comments parsing on map init (#18389)
This commit is contained in:
parent
42db392e76
commit
3e5f2541f2
9
vlib/v/fmt/tests/map_init_comments_keep.vv
Normal file
9
vlib/v/fmt/tests/map_init_comments_keep.vv
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
enum HttpHeader {
|
||||||
|
user_agent
|
||||||
|
referer
|
||||||
|
}
|
||||||
|
|
||||||
|
headers := {
|
||||||
|
HttpHeader.user_agent: 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.103 Safari/537.36' // content_length: '17' // <-- will be deleted
|
||||||
|
.referer: 'wwww.google.com' // content_length: '17' // <-- won't be deleted
|
||||||
|
}
|
@ -456,7 +456,8 @@ fn (mut p Parser) check_expr(precedence int) !ast.Expr {
|
|||||||
p.if_cond_comments << p.eat_comments()
|
p.if_cond_comments << p.eat_comments()
|
||||||
}
|
}
|
||||||
if p.pref.is_fmt && p.tok.kind == .comment && p.peek_tok.kind.is_infix() && !p.inside_infix
|
if p.pref.is_fmt && p.tok.kind == .comment && p.peek_tok.kind.is_infix() && !p.inside_infix
|
||||||
&& !(p.peek_tok.kind == .mul && p.peek_tok.pos().line_nr != p.tok.pos().line_nr) {
|
&& !p.inside_map_init && !(p.peek_tok.kind == .mul
|
||||||
|
&& p.peek_tok.pos().line_nr != p.tok.pos().line_nr) {
|
||||||
p.left_comments = p.eat_comments()
|
p.left_comments = p.eat_comments()
|
||||||
}
|
}
|
||||||
return p.expr_with_left(node, precedence, is_stmt_ident)
|
return p.expr_with_left(node, precedence, is_stmt_ident)
|
||||||
|
Loading…
Reference in New Issue
Block a user