mirror of
https://github.com/vlang/v.git
synced 2025-09-13 09:25:45 -04:00
parser: fix regression for v -e "import os; import math;"
, add a test to check it (#19353)
This commit is contained in:
parent
6f61d8ba78
commit
24cb98d5dc
@ -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'
|
||||
|
@ -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
|
||||
|
3
vlib/v/slow_tests/inout/oneliner_with_semicolons.out
Normal file
3
vlib/v/slow_tests/inout/oneliner_with_semicolons.out
Normal file
@ -0,0 +1,3 @@
|
||||
true
|
||||
1
|
||||
1.0
|
1
vlib/v/slow_tests/inout/oneliner_with_semicolons.vv
Normal file
1
vlib/v/slow_tests/inout/oneliner_with_semicolons.vv
Normal file
@ -0,0 +1 @@
|
||||
import os; import math; println(os.getenv('VEXE').len > 2); println(os.args.len); println(math.sin(math.pi / 2));
|
Loading…
x
Reference in New Issue
Block a user