mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
parser: fix error for match expr with 'fn' (#15805)
This commit is contained in:
@@ -238,7 +238,7 @@ fn (mut p Parser) match_expr() ast.MatchExpr {
|
|||||||
&& (((ast.builtin_type_names_matcher.matches(p.tok.lit) || p.tok.lit[0].is_capital())
|
&& (((ast.builtin_type_names_matcher.matches(p.tok.lit) || p.tok.lit[0].is_capital())
|
||||||
&& p.peek_tok.kind != .lpar) || (p.peek_tok.kind == .dot && p.peek_token(2).lit.len > 0
|
&& p.peek_tok.kind != .lpar) || (p.peek_tok.kind == .dot && p.peek_token(2).lit.len > 0
|
||||||
&& p.peek_token(2).lit[0].is_capital()))) || p.is_only_array_type()
|
&& p.peek_token(2).lit[0].is_capital()))) || p.is_only_array_type()
|
||||||
|| p.tok.lit == 'fn' {
|
|| p.tok.kind == .key_fn {
|
||||||
mut types := []ast.Type{}
|
mut types := []ast.Type{}
|
||||||
for {
|
for {
|
||||||
// Sum type match
|
// Sum type match
|
||||||
|
|||||||
10
vlib/v/tests/match_expr_with_string_fn_test.v
Normal file
10
vlib/v/tests/match_expr_with_string_fn_test.v
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
fn test_match_expr_with_string_fn() {
|
||||||
|
a := 'hello'
|
||||||
|
ret := match a {
|
||||||
|
'hello' { 1 }
|
||||||
|
'fn' { 2 }
|
||||||
|
else { 0 }
|
||||||
|
}
|
||||||
|
println(ret)
|
||||||
|
assert ret == 1
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user