mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
scanner: fix new string interpolation - print('{a}{{b}}') (#16309)
This commit is contained in:
parent
9de92eb391
commit
a979b3aab8
@ -811,7 +811,7 @@ fn (mut s Scanner) text_scan() token.Token {
|
||||
next_char := s.text[s.pos + 1]
|
||||
// Handle new `hello {name}` string interpolation
|
||||
if !s.is_inside_interpolation && !next_char.is_space() && next_char != `}`
|
||||
&& prev_char !in [`$`, `{`] {
|
||||
&& prev_char != `$` {
|
||||
s.is_inside_interpolation = true
|
||||
return s.new_token(.str_lcbr, '', 1)
|
||||
}
|
||||
|
@ -6,4 +6,13 @@ fn test_string_new_interpolation() {
|
||||
|
||||
println('{a} {b} {c} {d}')
|
||||
assert '{a} {b} {c} {d}' == '1 2 3 4'
|
||||
|
||||
println('{a}{{b}}')
|
||||
assert '{a}{{b}}' == '1{2}'
|
||||
|
||||
println('{a}\{{b}}')
|
||||
assert '{a}\{{b}}' == '1{2}'
|
||||
|
||||
println('{a}{{{{{b}}}}}')
|
||||
assert '{a}{{{{{b}}}}}' == '1{{{{2}}}}'
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user