checker: allow \uxxxxx in raw strings (#21724)

This commit is contained in:
Swastik Baranwal 2024-06-25 10:48:25 +05:30 committed by GitHub
parent e1d23429c7
commit a536c03365
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 9 additions and 0 deletions

View File

@ -3009,6 +3009,10 @@ pub fn (mut c Checker) expr(mut node ast.Expr) ast.Type {
// string literal starts with "c": `C.printf(c'hello')`
return ast.u8_type.set_nr_muls(1)
}
if node.is_raw {
// raw strings don't need any sort of checking related to unicode
return ast.string_type
}
return c.string_lit(mut node)
}
ast.StringInterLiteral {

View File

@ -17,6 +17,11 @@ fn test_raw_string_not_escaped_by_transformer() {
assert 'a\nb' + r'a\nb' == 'a\nba\\nb'
}
fn test_raw_string_backslash_u() {
assert r'\u0000004B' == r'\u0000004B'
println(r'\u0000004B')
}
// this test will cause test failure (see #12604)
// fn test_many_pluses() {
// a := r'x\n'