diff --git a/vlib/v/checker/checker.v b/vlib/v/checker/checker.v index db5f2a305a9500..cce4e04cd8a213 100644 --- a/vlib/v/checker/checker.v +++ b/vlib/v/checker/checker.v @@ -324,6 +324,7 @@ pub fn (mut c Checker) check_files(ast_files []&ast.File) { // println('check_files') // c.files = ast_files mut has_main_mod_file := false + mut has_no_main_mod_file := false mut has_main_fn := false unsafe { mut files_from_main_module := []&ast.File{} @@ -331,6 +332,9 @@ pub fn (mut c Checker) check_files(ast_files []&ast.File) { mut file := ast_files[i] c.timers.start('checker_check ${file.path}') c.check(mut file) + if file.mod.name == 'no_main' { + has_no_main_mod_file = true + } if file.mod.name == 'main' { files_from_main_module << file has_main_mod_file = true @@ -446,6 +450,9 @@ pub fn (mut c Checker) check_files(ast_files []&ast.File) { // This is useful for compiling linux kernel modules for example. return } + if has_no_main_mod_file { + return + } if !has_main_mod_file { c.error('project must include a `main` module or be a shared library (compile with `v -shared`)', token.Pos{})