1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

compiler: auto dereference mutable variable upon return

This commit is contained in:
Henrixounez 2019-08-18 18:45:48 +02:00 committed by Alexander Medvednikov
parent 14f13ff55a
commit 38db845378

View File

@ -3352,7 +3352,11 @@ fn (p mut Parser) return_st() {
} }
if total_text == '' || expr_type == 'void*' { if total_text == '' || expr_type == 'void*' {
if expr_type == '${p.cur_fn.typ}*' {
p.cgen.resetln('return *$ret')
} else {
p.cgen.resetln('return $ret') p.cgen.resetln('return $ret')
}
} else { } else {
tmp := p.get_tmp() tmp := p.get_tmp()
p.cgen.resetln('$expr_type $tmp = $ret;\n') p.cgen.resetln('$expr_type $tmp = $ret;\n')