checker: verify that there is a main module

pull/4743/head
Enzo Baldisserri 2020-05-06 00:09:46 +02:00 committed by GitHub
parent 25b536d03f
commit c1f224640f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 7 additions and 1 deletions

View File

@ -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{})
}
}

View 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
| ^

View File

@ -0,0 +1 @@
module a