File tree Expand file tree Collapse file tree 2 files changed +41
-4
lines changed Expand file tree Collapse file tree 2 files changed +41
-4
lines changed Original file line number Diff line number Diff line change
1
+ const ca = r 'x\n'
2
+
3
+ const cb = 'x\n '
4
+
5
+ const cc = ca + cb
6
+
7
+ const cd = cc + cc
8
+
9
+ const ce = cd + cd
10
+
1
11
fn test_raw_string_backslash () {
2
12
assert r '\' == r '\'
3
13
}
14
+
15
+ fn test_raw_string_not_escaped_by_transformer () {
16
+ assert r 'a\nb' + r 'a\nb' == r 'a\nba\nb'
17
+ assert 'a\n b' + r 'a\nb' == 'a\n ba\\ nb'
18
+ }
19
+
20
+ // this test will cause test failure (see #12604)
21
+ // fn test_many_pluses() {
22
+ // a := r'x\n'
23
+ // assert a == ca
24
+ // b := 'x\n'
25
+ // assert b == cb
26
+ // c := a + b
27
+ // assert c == cc // this fails
28
+ // d := c + c
29
+ // assert d == cd
30
+ // e := d + d
31
+ // assert e == ce
32
+ // println(e)
33
+ // result := r'x\nx
34
+ // x\nx
35
+ // x\nx
36
+ // x\nx
37
+ // '
38
+ // assert e == result
39
+ // }
Original file line number Diff line number Diff line change @@ -2,6 +2,7 @@ module transformer
2
2
3
3
import v.pref
4
4
import v.ast
5
+ import v.util
5
6
6
7
pub struct Transformer {
7
8
pref & pref.Preferences
@@ -379,10 +380,10 @@ pub fn (t Transformer) infix_expr(original ast.InfixExpr) ast.Expr {
379
380
}
380
381
}
381
382
.plus {
382
- return ast.StringLiteral{
383
- val: left_node.val + right_node.val
384
- pos: pos
385
- }
383
+ return if t.pref. backend == .c { ast. Expr ( ast.StringLiteral{
384
+ val: util. smart_quote ( left_node.val, left_node.is_raw) + util. smart_quote ( right_node.val, right_node.is_raw)
385
+ pos: pos
386
+ }) } else { ast. Expr (node) }
386
387
}
387
388
else {
388
389
return node
You can’t perform that action at this time.
0 commit comments