pull/13652/head
parent
9cc73fd0f8
commit
63b41e67fa
|
@ -466,10 +466,10 @@ fn (mut p Parser) fn_decl() ast.FnDecl {
|
|||
// Body
|
||||
p.cur_fn_name = name
|
||||
mut stmts := []ast.Stmt{}
|
||||
body_start_pos := p.peek_tok.pos()
|
||||
body_start_pos := p.tok.pos()
|
||||
if p.tok.kind == .lcbr {
|
||||
if language != .v && language != .js {
|
||||
p.error_with_pos('interop functions cannot have a body', p.tok.pos())
|
||||
p.error_with_pos('interop functions cannot have a body', body_start_pos)
|
||||
}
|
||||
p.inside_fn = true
|
||||
p.inside_unsafe_fn = is_unsafe
|
||||
|
|
|
@ -0,0 +1,3 @@
|
|||
vlib/v/parser/tests/fn_body_start_pos.vv:1:14: error: functions with type only args can not have bodies
|
||||
1 | fn func(int) {}
|
||||
| ^
|
|
@ -0,0 +1 @@
|
|||
fn func(int) {}
|
|
@ -1,6 +1,5 @@
|
|||
vlib/v/parser/tests/fn_type_only_args_no_body.vv:2:1: error: functions with type only args can not have bodies
|
||||
vlib/v/parser/tests/fn_type_only_args_no_body.vv:1:14: error: functions with type only args can not have bodies
|
||||
1 | fn test(int) {
|
||||
| ^
|
||||
2 | }
|
||||
| ^
|
||||
3 |
|
||||
4 | fn main() {
|
||||
3 |
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
vlib/v/parser/tests/fn_type_only_args_unknown_name.vv:2:1: error: functions with type only args can not have bodies
|
||||
vlib/v/parser/tests/fn_type_only_args_unknown_name.vv:1:16: error: functions with type only args can not have bodies
|
||||
1 | fn test(param) {
|
||||
| ^
|
||||
2 | }
|
||||
| ^
|
||||
3 |
|
||||
4 | fn main() {
|
||||
3 |
|
||||
|
|
Loading…
Reference in New Issue