mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
parser: fix anon_fn with array arguments (#9414)
This commit is contained in:
parent
c5bc349edb
commit
cf6faaf215
@ -643,7 +643,7 @@ fn (mut p Parser) fn_args() ([]table.Param, bool, bool) {
|
|||||||
} else {
|
} else {
|
||||||
p.tok.lit
|
p.tok.lit
|
||||||
}
|
}
|
||||||
types_only := p.tok.kind in [.amp, .ellipsis, .key_fn]
|
types_only := p.tok.kind in [.amp, .ellipsis, .key_fn, .lsbr]
|
||||||
|| (p.peek_tok.kind == .comma && p.table.known_type(argname))
|
|| (p.peek_tok.kind == .comma && p.table.known_type(argname))
|
||||||
|| p.peek_tok.kind == .dot || p.peek_tok.kind == .rpar
|
|| p.peek_tok.kind == .dot || p.peek_tok.kind == .rpar
|
||||||
// TODO copy pasta, merge 2 branches
|
// TODO copy pasta, merge 2 branches
|
||||||
|
12
vlib/v/tests/anon_fn_with_array_arguments.v
Normal file
12
vlib/v/tests/anon_fn_with_array_arguments.v
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
fn fn_arg(f fn ([]int) int) int {
|
||||||
|
return f([1, 2, 3])
|
||||||
|
}
|
||||||
|
|
||||||
|
fn test_anon_fn_with_array_arguments() {
|
||||||
|
anon := fn (i []int) int {
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
|
println(fn_arg(anon))
|
||||||
|
assert fn_arg(anon) == 0
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user