mirror of
https://github.com/vlang/v.git
synced 2025-09-14 18:06:48 -04:00
checker: fix missing check for escape char on unicode checker (#22462)
This commit is contained in:
parent
98f66d803a
commit
875faaff0f
@ -143,7 +143,10 @@ fn (mut c Checker) string_lit(mut node ast.StringLiteral) ast.Type {
|
|||||||
start_idx := idx
|
start_idx := idx
|
||||||
idx++
|
idx++
|
||||||
next_ch := node.val[idx] or { return ast.string_type }
|
next_ch := node.val[idx] or { return ast.string_type }
|
||||||
if next_ch == `u` {
|
if next_ch == `\\` {
|
||||||
|
// ignore escaping char
|
||||||
|
idx++
|
||||||
|
} else if next_ch == `u` {
|
||||||
idx++
|
idx++
|
||||||
mut ch := node.val[idx] or { return ast.string_type }
|
mut ch := node.val[idx] or { return ast.string_type }
|
||||||
mut hex_char_count := 0
|
mut hex_char_count := 0
|
||||||
|
9
vlib/v/tests/unicode_escape_test.v
Normal file
9
vlib/v/tests/unicode_escape_test.v
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
fn test_main() {
|
||||||
|
a := r'\u306aefgh\t'
|
||||||
|
|
||||||
|
mut expected := '\\u306a'
|
||||||
|
expected += 'efgh\\t'
|
||||||
|
|
||||||
|
assert a == expected
|
||||||
|
assert a == '\\u306aefgh\\t'
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user