parser: check fn decl multi return types without parentheses (#14508)
parent
b717ef74f8
commit
96b80bcf9f
|
@ -400,6 +400,11 @@ fn (mut p Parser) fn_decl() ast.FnDecl {
|
||||||
p.inside_fn_return = false
|
p.inside_fn_return = false
|
||||||
return_type_pos = return_type_pos.extend(p.prev_tok.pos())
|
return_type_pos = return_type_pos.extend(p.prev_tok.pos())
|
||||||
}
|
}
|
||||||
|
if p.tok.kind == .comma {
|
||||||
|
mr_pos := return_type_pos.extend(p.peek_tok.pos())
|
||||||
|
p.error_with_pos('multiple return types in function declaration must use parentheses, .e.g (int, string)',
|
||||||
|
mr_pos)
|
||||||
|
}
|
||||||
mut type_sym_method_idx := 0
|
mut type_sym_method_idx := 0
|
||||||
no_body := p.tok.kind != .lcbr
|
no_body := p.tok.kind != .lcbr
|
||||||
end_pos := p.prev_tok.pos()
|
end_pos := p.prev_tok.pos()
|
||||||
|
|
|
@ -0,0 +1,7 @@
|
||||||
|
vlib/v/parser/tests/fn_decl_multi_return_types_err.vv:4:10: error: multiple return types in function declaration must use parentheses, .e.g (int, string)
|
||||||
|
2 | }
|
||||||
|
3 |
|
||||||
|
4 | fn foo() int, int {
|
||||||
|
| ~~~~~~~~
|
||||||
|
5 | return 0, 0
|
||||||
|
6 | }
|
|
@ -0,0 +1,6 @@
|
||||||
|
fn main() {
|
||||||
|
}
|
||||||
|
|
||||||
|
fn foo() int, int {
|
||||||
|
return 0, 0
|
||||||
|
}
|
Loading…
Reference in New Issue