parser: fix anon_fn with array arguments (#9414)
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
|
||||||
|
|
|
@ -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