Skip to content

Commit

Permalink
scanner: fix string interpolation with match expr (#18969)
Browse files Browse the repository at this point in the history
  • Loading branch information
yuyi98 committed Jul 26, 2023
1 parent e03c032 commit b35ad8a
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
2 changes: 1 addition & 1 deletion vlib/v/scanner/scanner.v
Expand Up @@ -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 {
Expand Down
15 changes: 15 additions & 0 deletions vlib/v/tests/string_interpolation_match_expr_test.v
@@ -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'
}

0 comments on commit b35ad8a

Please sign in to comment.