mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
checker: verify that there is a main module
This commit is contained in:
@ -89,7 +89,9 @@ pub fn (mut c Checker) check_files(ast_files []ast.File) {
|
||||
// shared libs do not need to have a main
|
||||
return
|
||||
}
|
||||
if has_main_mod_file && !has_main_fn {
|
||||
if !has_main_mod_file {
|
||||
c.error('projet must include a `main` module or be a shared library (compile with `v -shared`)', token.Position{})
|
||||
} else if !has_main_fn {
|
||||
c.error('function `main` must be declared in the main module', token.Position{})
|
||||
}
|
||||
}
|
||||
|
3
vlib/v/checker/tests/no_main_mod.out
Normal file
3
vlib/v/checker/tests/no_main_mod.out
Normal file
@ -0,0 +1,3 @@
|
||||
vlib/v/checker/tests/no_main_mod.v:1:1: error: projet must include a `main` module or be a shared library (compile with `v -shared`)
|
||||
1 | module a
|
||||
| ^
|
1
vlib/v/checker/tests/no_main_mod.vv
Normal file
1
vlib/v/checker/tests/no_main_mod.vv
Normal file
@ -0,0 +1 @@
|
||||
module a
|
Reference in New Issue
Block a user