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

parser: fix printing slice of multiline raw string (#13856)

This commit is contained in:
yuyi 2022-03-29 23:06:11 +08:00 committed by GitHub
parent c71770d9c5
commit 42a67831bf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 11 additions and 1 deletions

View File

@ -372,7 +372,9 @@ pub fn (mut p Parser) expr_with_left(left ast.Expr, precedence int, is_stmt_iden
return node
}
p.is_stmt_ident = is_stmt_ident
} else if p.tok.kind in [.lsbr, .nilsbr] && p.tok.line_nr == p.prev_tok.line_nr {
} else if p.tok.kind in [.lsbr, .nilsbr] && (p.tok.line_nr == p.prev_tok.line_nr
|| (p.prev_tok.kind == .string
&& p.tok.line_nr == p.prev_tok.line_nr + p.prev_tok.lit.count('\n'))) {
if p.tok.kind == .nilsbr {
node = p.index_expr(node, true)
} else {

View File

@ -0,0 +1,3 @@
foo
bar
hi

View File

@ -0,0 +1,5 @@
fn main() {
println(r'foo
bar
hi'[..])
}