checker: fix const type with raw string literal (#12761)
parent
cd96f980cc
commit
d88e67a5ec
|
@ -8732,7 +8732,7 @@ fn (mut c Checker) eval_comptime_const_expr(expr ast.Expr, nlevel int) ?ast.Comp
|
|||
return expr.val.i64()
|
||||
}
|
||||
ast.StringLiteral {
|
||||
return expr.val
|
||||
return util.smart_quote(expr.val, expr.is_raw)
|
||||
}
|
||||
ast.CharLiteral {
|
||||
runes := expr.val.runes()
|
||||
|
|
|
@ -0,0 +1,29 @@
|
|||
const ca = r'x\n'
|
||||
|
||||
const cb = 'x\n'
|
||||
|
||||
const cc = ca + cb
|
||||
|
||||
const cd = cc + cc
|
||||
|
||||
const ce = cd + cd
|
||||
|
||||
fn test_many_pluses_with_raw_string_literal() {
|
||||
a := r'x\n'
|
||||
assert a == ca
|
||||
b := 'x\n'
|
||||
assert b == cb
|
||||
c := a + b
|
||||
assert c == cc
|
||||
d := c + c
|
||||
assert d == cd
|
||||
e := d + d
|
||||
assert e == ce
|
||||
println(e)
|
||||
result := r'x\nx
|
||||
x\nx
|
||||
x\nx
|
||||
x\nx
|
||||
'
|
||||
assert e == result
|
||||
}
|
Loading…
Reference in New Issue