Skip to content

Commit cf6faaf

Browse files
authored
parser: fix anon_fn with array arguments (#9414)
1 parent c5bc349 commit cf6faaf

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

vlib/v/parser/fn.v

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -643,7 +643,7 @@ fn (mut p Parser) fn_args() ([]table.Param, bool, bool) {
643643
} else {
644644
p.tok.lit
645645
}
646-
types_only := p.tok.kind in [.amp, .ellipsis, .key_fn]
646+
types_only := p.tok.kind in [.amp, .ellipsis, .key_fn, .lsbr]
647647
|| (p.peek_tok.kind == .comma && p.table.known_type(argname))
648648
|| p.peek_tok.kind == .dot || p.peek_tok.kind == .rpar
649649
// TODO copy pasta, merge 2 branches
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
fn fn_arg(f fn ([]int) int) int {
2+
return f([1, 2, 3])
3+
}
4+
5+
fn test_anon_fn_with_array_arguments() {
6+
anon := fn (i []int) int {
7+
return 0
8+
}
9+
10+
println(fn_arg(anon))
11+
assert fn_arg(anon) == 0
12+
}

0 commit comments

Comments
 (0)