checker: disallow pub fn main()

pull/4461/head
Kris Cherven 2020-04-17 14:30:43 -04:00 committed by GitHub
parent c4b7d7cab3
commit 84ac634c31
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 0 deletions

View File

@ -79,6 +79,10 @@ pub fn (c mut Checker) check_files(ast_files []ast.File) {
if all_mods['main'] > 0 {
for i, f in c.table.fns {
if f.name == 'main' {
if f.is_pub {
c.error('function `main` cannot be declared public', token.Position{})
exit(1)
}
return
}
}