diff --git a/vlib/v/fmt/tests/no_main_expected.vv b/vlib/v/fmt/tests/no_main_expected.vv new file mode 100644 index 0000000000..2a082f98cb --- /dev/null +++ b/vlib/v/fmt/tests/no_main_expected.vv @@ -0,0 +1 @@ +println('hello world') diff --git a/vlib/v/fmt/tests/no_main_input.vv b/vlib/v/fmt/tests/no_main_input.vv new file mode 100644 index 0000000000..d77431408d --- /dev/null +++ b/vlib/v/fmt/tests/no_main_input.vv @@ -0,0 +1 @@ +println( "hello world" ) diff --git a/vlib/v/parser/parser.v b/vlib/v/parser/parser.v index 38c2861307..1a93c68cca 100644 --- a/vlib/v/parser/parser.v +++ b/vlib/v/parser/parser.v @@ -452,6 +452,8 @@ pub fn (mut p Parser) top_stmt() ast.Stmt { file: p.file_name return_type: table.void_type } + } else if p.pref.is_fmt { + return p.stmt(false) } else { p.error('bad top level statement ' + p.tok.str()) return ast.Stmt{}