mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
checker: make the no-body main function a checker error (#8211)
This commit is contained in:
parent
325731e3b6
commit
9812230847
@ -246,6 +246,9 @@ fn (mut c Checker) check_file_in_main(file ast.File) bool {
|
||||
if stmt.return_type != table.void_type {
|
||||
c.error('function `main` cannot return values', stmt.pos)
|
||||
}
|
||||
if stmt.no_body {
|
||||
c.error('function `main` must declare a body', stmt.pos)
|
||||
}
|
||||
} else {
|
||||
for attr in stmt.attrs {
|
||||
if attr.name == 'console' {
|
||||
|
3
vlib/v/checker/tests/main_no_body_err.out
Normal file
3
vlib/v/checker/tests/main_no_body_err.out
Normal file
@ -0,0 +1,3 @@
|
||||
vlib/v/checker/tests/main_no_body_err.vv:1:1: error: function `main` must declare a body
|
||||
1 | fn main()
|
||||
| ~~~~~~~~~
|
1
vlib/v/checker/tests/main_no_body_err.vv
Normal file
1
vlib/v/checker/tests/main_no_body_err.vv
Normal file
@ -0,0 +1 @@
|
||||
fn main()
|
Loading…
Reference in New Issue
Block a user