1
0
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:
yuyi 2022-07-30 00:10:50 +08:00 committed by GitHub
parent 0bf23488dc
commit 1be595605a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 18 additions and 1 deletions

View File

@ -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)

View File

@ -0,0 +1 @@
test

View 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
}
}