1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

scanner: fix string interpolation with match expr (#18969)

This commit is contained in:
yuyi 2023-07-26 16:27:20 +08:00 committed by GitHub
parent e03c0329c1
commit b35ad8a657
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 1 deletions

View File

@ -808,7 +808,7 @@ fn (mut s Scanner) text_scan() token.Token {
}
`{` {
// Skip { in `${` in strings
if s.is_inside_string {
if s.is_inside_string || s.is_enclosed_inter {
if s.text[s.pos - 1] == `$` {
continue
} else {

View File

@ -0,0 +1,15 @@
fn test_string_interpolation_match_expr() {
x := 0
println('Hello ${match x {
0 { 'John' }
1 { 'George' }
else { 'Others' }
}}')
assert '${match x {
0 { 'John' }
1 { 'George' }
else { 'Others' }
}}' == 'John'
}