diff --git a/vlib/v/parser/parser.v b/vlib/v/parser/parser.v index 47d94ffe8d..84349d63ab 100644 --- a/vlib/v/parser/parser.v +++ b/vlib/v/parser/parser.v @@ -302,6 +302,9 @@ pub fn (mut p Parser) top_stmt() ast.Stmt { } .key_import { node := p.import_stmt() + if node.len == 0 { + return p.top_stmt() + } p.ast_imports << node return node[0] } diff --git a/vlib/v/tests/inout/empty_import.out b/vlib/v/tests/inout/empty_import.out new file mode 100644 index 0000000000..c1e44f4f09 --- /dev/null +++ b/vlib/v/tests/inout/empty_import.out @@ -0,0 +1 @@ +empty import \ No newline at end of file diff --git a/vlib/v/tests/inout/empty_import.vv b/vlib/v/tests/inout/empty_import.vv new file mode 100644 index 0000000000..ada986a14a --- /dev/null +++ b/vlib/v/tests/inout/empty_import.vv @@ -0,0 +1,7 @@ +import ( + // no module +) + +fn main() { + println('empty import') +}