mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
v.parser: fix -autofree for script mode programs that do not have explicit fn main(){}
This commit is contained in:
parent
ce7f78522d
commit
13d1d28db1
@ -575,10 +575,12 @@ pub fn (mut p Parser) top_stmt() ast.Stmt {
|
||||
else {
|
||||
p.inside_fn = true
|
||||
if p.pref.is_script && !p.pref.is_test {
|
||||
p.open_scope()
|
||||
mut stmts := []ast.Stmt{}
|
||||
for p.tok.kind != .eof {
|
||||
stmts << p.stmt(false)
|
||||
}
|
||||
p.close_scope()
|
||||
return ast.FnDecl{
|
||||
name: 'main.main'
|
||||
mod: 'main'
|
||||
|
5
vlib/v/tests/valgrind/simple_interpolation.v
Normal file
5
vlib/v/tests/valgrind/simple_interpolation.v
Normal file
@ -0,0 +1,5 @@
|
||||
fn main() {
|
||||
v := 't'
|
||||
s := '${v}.tmp'
|
||||
println(s)
|
||||
}
|
5
vlib/v/tests/valgrind/simple_interpolation_script_mode.v
Normal file
5
vlib/v/tests/valgrind/simple_interpolation_script_mode.v
Normal file
@ -0,0 +1,5 @@
|
||||
v := 't'
|
||||
|
||||
s := '${v}.tmp'
|
||||
|
||||
println(s)
|
@ -0,0 +1,7 @@
|
||||
{
|
||||
{
|
||||
v := 't'
|
||||
s := '${v}.tmp'
|
||||
println(s)
|
||||
}
|
||||
}
|
@ -78,6 +78,7 @@ fn test_all() {
|
||||
bench.fail()
|
||||
eprintln(bench.step_message_fail('file: $test could not be compiled.'))
|
||||
eprintln(res.output)
|
||||
eprintln('You can reproduce the failure with:\n$compile_cmd')
|
||||
continue
|
||||
}
|
||||
if test in skip_valgrind_files {
|
||||
@ -94,6 +95,7 @@ fn test_all() {
|
||||
bench.fail()
|
||||
eprintln(bench.step_message_fail('failed valgrind check for ${util.bold(test)}'))
|
||||
eprintln(valgrind_res.output)
|
||||
eprintln('You can reproduce the failure with:\n$compile_cmd && $valgrind_cmd')
|
||||
continue
|
||||
}
|
||||
bench.ok()
|
||||
|
Loading…
Reference in New Issue
Block a user