mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
parser: fix error for match sumtype with fntype (#15620)
This commit is contained in:
parent
6110373519
commit
806c39d46e
@ -237,7 +237,8 @@ fn (mut p Parser) match_expr() ast.MatchExpr {
|
||||
} else if (p.tok.kind == .name && !(p.tok.lit == 'C' && p.peek_tok.kind == .dot)
|
||||
&& (((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_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' {
|
||||
mut types := []ast.Type{}
|
||||
for {
|
||||
// Sum type match
|
||||
|
@ -2,5 +2,7 @@ Fn(fn () int)
|
||||
Fn(fn (int) int)
|
||||
123
|
||||
123
|
||||
123
|
||||
321
|
||||
321
|
||||
321
|
||||
|
@ -23,10 +23,24 @@ fn main() {
|
||||
println(x1())
|
||||
}
|
||||
|
||||
match x1 {
|
||||
fn () int {
|
||||
println(x1())
|
||||
}
|
||||
else {}
|
||||
}
|
||||
|
||||
x2 := abc(2)
|
||||
y2 := x2 as fn (int) int
|
||||
println(y2(321))
|
||||
if x2 is fn (int) int {
|
||||
println(x2(321))
|
||||
}
|
||||
|
||||
match x2 {
|
||||
fn (int) int {
|
||||
println(x2(321))
|
||||
}
|
||||
else {}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user