mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
parser: fix optional fn argument (#15271)
This commit is contained in:
parent
0bf23488dc
commit
1be595605a
@ -379,7 +379,7 @@ pub fn (mut p Parser) parse_type() ast.Type {
|
|||||||
p.next()
|
p.next()
|
||||||
is_result = true
|
is_result = true
|
||||||
}
|
}
|
||||||
if (is_optional || is_result) && p.tok.line_nr > line_nr {
|
if (is_optional || is_result) && (p.tok.line_nr > line_nr || p.tok.kind in [.comma, .rpar]) {
|
||||||
mut typ := ast.void_type
|
mut typ := ast.void_type
|
||||||
if is_optional {
|
if is_optional {
|
||||||
typ = typ.set_flag(.optional)
|
typ = typ.set_flag(.optional)
|
||||||
|
1
vlib/v/tests/inout/optional_fn_arg.out
Normal file
1
vlib/v/tests/inout/optional_fn_arg.out
Normal file
@ -0,0 +1 @@
|
|||||||
|
test
|
16
vlib/v/tests/inout/optional_fn_arg.vv
Normal file
16
vlib/v/tests/inout/optional_fn_arg.vv
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
module main
|
||||||
|
|
||||||
|
fn test(f fn () ?) ? {
|
||||||
|
return error('test')
|
||||||
|
}
|
||||||
|
|
||||||
|
fn test1() ? {
|
||||||
|
return error('test1')
|
||||||
|
}
|
||||||
|
|
||||||
|
fn main() {
|
||||||
|
test(test1) or {
|
||||||
|
println(err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user