mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
checker: fix check main function error (#4601)
This commit is contained in:
parent
a48080afec
commit
3a59f5727c
@ -60,10 +60,12 @@ pub fn (mut c Checker) check2(ast_file ast.File) []scanner.Error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn (mut c Checker) check_files(ast_files []ast.File) {
|
pub fn (mut c Checker) check_files(ast_files []ast.File) {
|
||||||
|
mut has_main_mod_file := false
|
||||||
mut has_main_fn := false
|
mut has_main_fn := false
|
||||||
for file in ast_files {
|
for file in ast_files {
|
||||||
c.check(file)
|
c.check(file)
|
||||||
if file.mod.name == 'main' {
|
if file.mod.name == 'main' {
|
||||||
|
has_main_mod_file = true
|
||||||
if c.check_file_in_main(file) {
|
if c.check_file_in_main(file) {
|
||||||
has_main_fn = true
|
has_main_fn = true
|
||||||
}
|
}
|
||||||
@ -77,7 +79,7 @@ pub fn (mut c Checker) check_files(ast_files []ast.File) {
|
|||||||
// shared libs do not need to have a main
|
// shared libs do not need to have a main
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if !has_main_fn {
|
if has_main_mod_file && !has_main_fn {
|
||||||
c.error('function `main` must be declared in the main module', token.Position{})
|
c.error('function `main` must be declared in the main module', token.Position{})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user