checker: make the no-body main function a checker error (#8211)
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' {
|
||||
|
|
|
@ -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()
|
||||
| ~~~~~~~~~
|
|
@ -0,0 +1 @@
|
|||
fn main()
|
Loading…
Reference in New Issue