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

pull/13865/head
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'[..])
}