diff --git a/examples/database/mysql.v b/examples/database/mysql.v index 72ac398a99..bb1d7ce84b 100644 --- a/examples/database/mysql.v +++ b/examples/database/mysql.v @@ -9,3 +9,7 @@ // res.free() // conn.close() // } + +fn main() { + +} diff --git a/examples/database/pg/customer.v b/examples/database/pg/customer.v index 46e19e3d3d..4f62282a27 100644 --- a/examples/database/pg/customer.v +++ b/examples/database/pg/customer.v @@ -57,3 +57,7 @@ fn main() { } */ + +fn main() { + +} diff --git a/vlib/compiler/main.v b/vlib/compiler/main.v index 0e5d40c0cb..94f31d90b7 100644 --- a/vlib/compiler/main.v +++ b/vlib/compiler/main.v @@ -439,7 +439,7 @@ pub fn (v mut V) generate_main() { cgen.genln('$cgen.fn_main;') v.gen_main_end('return 0') } - else { + else if !v.pref.is_repl { verror('function `main` is not declared in the main module') } } @@ -453,7 +453,9 @@ pub fn (v mut V) generate_main() { // Generate a C `main`, which calls every single test function v.gen_main_start(false) - if v.pref.is_stats { cgen.genln('BenchedTests bt = main__start_testing();') } + if v.pref.is_stats { + cgen.genln('BenchedTests bt = main__start_testing();') + } for _, f in v.table.fns { if f.name.starts_with('main__test_') {