mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
autofree: fix unused var error
This commit is contained in:
parent
91007e87d2
commit
159abd4727
@ -1037,12 +1037,12 @@ fn (mut g Gen) stmt(node ast.Stmt) {
|
||||
}
|
||||
ast.Return {
|
||||
g.write_defer_stmts_when_needed()
|
||||
af := g.pref.autofree && node.exprs.len > 0 && node.exprs[0] is ast.CallExpr && !g.is_builtin_mod
|
||||
if g.pref.autofree {
|
||||
// af := g.pref.autofree && node.exprs.len > 0 && node.exprs[0] is ast.CallExpr && !g.is_builtin_mod
|
||||
af := g.pref.autofree && !g.is_builtin_mod
|
||||
if af {
|
||||
g.writeln('// ast.Return free')
|
||||
// g.autofree_scope_vars(node.pos.pos - 1, node.pos.line_nr, true)
|
||||
g.writeln('// ast.Return free_end')
|
||||
// g.write_autofree_stmts_when_needed(node)
|
||||
}
|
||||
g.return_statement(node)
|
||||
}
|
||||
|
@ -181,17 +181,6 @@ fn (mut g Gen) gen_fn_decl(it ast.FnDecl, skip bool) {
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
fn (mut g Gen) write_autofree_stmts_when_needed(r ast.Return) {
|
||||
// TODO: write_autofree_stmts_when_needed should account for the current local scope vars.
|
||||
// TODO: write_autofree_stmts_when_needed should not free the returned variables.
|
||||
// It may require rewriting g.return_statement to assign the expressions
|
||||
// to temporary variables, then protecting *them* from autofreeing ...
|
||||
// g.writeln('// autofreeings before return: -------')
|
||||
// g.writeln(g.autofree_scope_vars(g.fn_decl.body_pos.pos))
|
||||
// g.writeln('//--------------------------------------------------- ') // //g.write( g.autofree_scope_vars(r.pos.pos) )
|
||||
}
|
||||
*/
|
||||
fn (mut g Gen) write_defer_stmts_when_needed() {
|
||||
if g.defer_stmts.len > 0 {
|
||||
g.write_defer_stmts()
|
||||
|
Loading…
Reference in New Issue
Block a user