diff --git a/cmd/tools/vtest-all.v b/cmd/tools/vtest-all.v index a1f4adc16c..e7afe40487 100644 --- a/cmd/tools/vtest-all.v +++ b/cmd/tools/vtest-all.v @@ -101,6 +101,12 @@ fn get_all_commands() []Command { runcmd: .execute expect: '42' } + res << Command{ + line: '${vexe} -e "import os; import math; print(os.args#[1..]) print(math.sin(math.pi/2).str())" arg1 arg2' + okmsg: 'V can run code with `-e`, that use semicolons and several imports, and that accepts CLI parameters.' + runcmd: .execute + expect: "['arg1', 'arg2']1.0" + } $if linux || macos { res << Command{ line: '${vexe} run examples/hello_world.v' diff --git a/vlib/v/parser/parser.v b/vlib/v/parser/parser.v index 5f7ce9e7f0..dd39c7cafc 100644 --- a/vlib/v/parser/parser.v +++ b/vlib/v/parser/parser.v @@ -3666,6 +3666,9 @@ fn (mut p Parser) import_stmt() ast.Import { import_node.comments = p.eat_comments(same_line: true) import_node.next_comments = p.eat_comments(follow_up: true) p.imports[mod_alias] = mod_name + if p.tok.kind == .semicolon { + p.check(.semicolon) + } // if mod_name !in p.table.imports { p.table.imports << mod_name p.ast_imports << import_node diff --git a/vlib/v/slow_tests/inout/oneliner_with_semicolons.out b/vlib/v/slow_tests/inout/oneliner_with_semicolons.out new file mode 100644 index 0000000000..8de0bad24b --- /dev/null +++ b/vlib/v/slow_tests/inout/oneliner_with_semicolons.out @@ -0,0 +1,3 @@ +true +1 +1.0 diff --git a/vlib/v/slow_tests/inout/oneliner_with_semicolons.vv b/vlib/v/slow_tests/inout/oneliner_with_semicolons.vv new file mode 100644 index 0000000000..19a1147d37 --- /dev/null +++ b/vlib/v/slow_tests/inout/oneliner_with_semicolons.vv @@ -0,0 +1 @@ +import os; import math; println(os.getenv('VEXE').len > 2); println(os.args.len); println(math.sin(math.pi / 2));