scanner: add check for `!is_raw` for null `\0` (#6427)
parent
4b0e7fc979
commit
1c886ad067
|
@ -725,6 +725,10 @@ fn test_raw() {
|
|||
println(lines)
|
||||
assert lines.len == 1
|
||||
println('raw string: "$raw"')
|
||||
|
||||
raw2 := r'Hello V\0'
|
||||
assert raw2[7] == `\\`
|
||||
assert raw2[8] == `0`
|
||||
}
|
||||
|
||||
fn test_raw_with_quotes() {
|
||||
|
|
|
@ -1217,14 +1217,14 @@ fn (mut s Scanner) ident_string() string {
|
|||
// Don't allow \0
|
||||
if c == `0` && s.pos > 2 && s.text[s.pos - 1] == slash {
|
||||
if (s.pos < s.text.len - 1 && s.text[s.pos + 1].is_digit()) || s.count_symbol_before(s.pos - 1, slash) % 2 == 0 {
|
||||
} else if !is_cstr {
|
||||
} else if !is_cstr && !is_raw {
|
||||
s.error('0 character in a string literal')
|
||||
}
|
||||
}
|
||||
// Don't allow \x00
|
||||
if c == `0` && s.pos > 5 && s.expect('\\x0', s.pos - 3) {
|
||||
if s.count_symbol_before(s.pos - 3, slash) % 2 == 0 {
|
||||
} else if !is_cstr {
|
||||
} else if !is_cstr && !is_raw {
|
||||
s.error('0 character in a string literal')
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue