1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

parser: fix the no fn main error in script mode

This commit is contained in:
Alexander Medvednikov 2019-11-18 00:40:59 +03:00
parent ffb72e855a
commit 4fb0b49806

View File

@ -432,7 +432,8 @@ pub fn (v mut V) generate_main() {
if v.pref.build_mode != .build_module {
if !v.table.main_exists() && !v.pref.is_test {
// It can be skipped in single file programs
if v.pref.is_script {
// But make sure that there's some code outside of main()
if v.pref.is_script && cgen.fn_main.trim_space() != ''{
//println('Generating main()...')
v.gen_main_start(true)
cgen.genln('$cgen.fn_main;')