Skip to content

Commit

Permalink
checker: allow \uxxxxx in raw strings (vlang#21724)
Browse files Browse the repository at this point in the history
  • Loading branch information
Delta456 authored and raw-bin committed Jul 2, 2024
1 parent 7c3a8b9 commit dc37408
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
4 changes: 4 additions & 0 deletions vlib/v/checker/checker.v
Original file line number Diff line number Diff line change
Expand Up @@ -3013,6 +3013,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 {
Expand Down
5 changes: 5 additions & 0 deletions vlib/v/tests/raw_string_test.v
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down

0 comments on commit dc37408

Please sign in to comment.