v.parser: fix -autofree for script mode programs that do not have explicit `fn main(){}`
parent
ce7f78522d
commit
13d1d28db1
|
@ -575,10 +575,12 @@ pub fn (mut p Parser) top_stmt() ast.Stmt {
|
||||||
else {
|
else {
|
||||||
p.inside_fn = true
|
p.inside_fn = true
|
||||||
if p.pref.is_script && !p.pref.is_test {
|
if p.pref.is_script && !p.pref.is_test {
|
||||||
|
p.open_scope()
|
||||||
mut stmts := []ast.Stmt{}
|
mut stmts := []ast.Stmt{}
|
||||||
for p.tok.kind != .eof {
|
for p.tok.kind != .eof {
|
||||||
stmts << p.stmt(false)
|
stmts << p.stmt(false)
|
||||||
}
|
}
|
||||||
|
p.close_scope()
|
||||||
return ast.FnDecl{
|
return ast.FnDecl{
|
||||||
name: 'main.main'
|
name: 'main.main'
|
||||||
mod: 'main'
|
mod: 'main'
|
||||||
|
|
|
@ -0,0 +1,5 @@
|
||||||
|
fn main() {
|
||||||
|
v := 't'
|
||||||
|
s := '${v}.tmp'
|
||||||
|
println(s)
|
||||||
|
}
|
|
@ -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()
|
bench.fail()
|
||||||
eprintln(bench.step_message_fail('file: $test could not be compiled.'))
|
eprintln(bench.step_message_fail('file: $test could not be compiled.'))
|
||||||
eprintln(res.output)
|
eprintln(res.output)
|
||||||
|
eprintln('You can reproduce the failure with:\n$compile_cmd')
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
if test in skip_valgrind_files {
|
if test in skip_valgrind_files {
|
||||||
|
@ -94,6 +95,7 @@ fn test_all() {
|
||||||
bench.fail()
|
bench.fail()
|
||||||
eprintln(bench.step_message_fail('failed valgrind check for ${util.bold(test)}'))
|
eprintln(bench.step_message_fail('failed valgrind check for ${util.bold(test)}'))
|
||||||
eprintln(valgrind_res.output)
|
eprintln(valgrind_res.output)
|
||||||
|
eprintln('You can reproduce the failure with:\n$compile_cmd && $valgrind_cmd')
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
bench.ok()
|
bench.ok()
|
||||||
|
|
Loading…
Reference in New Issue