fix prod build

pull/4097/head
Alexander Medvednikov 2020-03-21 20:02:37 +01:00
parent e5f6a0949f
commit 3e80e22f5d
3 changed files with 35 additions and 2 deletions

View File

@ -552,7 +552,7 @@ fn (g mut Gen) gen_fn_decl(it ast.FnDecl) {
// ////////////
if g.autofree && false {
scope := g.file.scope.innermost(it.pos.pos - 1)
for i, var in scope.vars {
for _, var in scope.vars {
sym := g.table.get_type_symbol(var.typ)
if sym.kind == .array && !table.type_is_optional(var.typ) {
g.writeln('array_free($var.name); // autofree')
@ -1837,8 +1837,8 @@ fn (g mut Gen) call_expr(it ast.CallExpr) {
name = name[3..]
}
// Generate tmp vars for values that have to be freed.
mut tmps := []string
/*
mut tmps := []string
for arg in it.args {
if arg.typ == table.string_type_idx || is_print {
tmp := g.new_tmp_var()

View File

@ -0,0 +1,18 @@
import os
fn return_array(array_arg []string) []int {
s := [1, 2, 3] // escaping array must not be freed
return s
}
fn foo() {
nums := [1, 2, 3] // local array must be freed
println(nums)
}
fn main() {
println('start')
foo()
println('end')
}

View File

@ -0,0 +1,15 @@
import os
import term
fn test_all() {
$if !linux {
println('Valgrind tests can only be run on Linux.')
exit(1)
}
exe := os.executable()
dir := os.dir(exe)
files := os.ls('$dir/vlib/v/tests/valgrind/') or {
panic(err)
}
println(files)
}