compiler: auto dereference mutable variable upon return

pull/1661/head
Henrixounez 2019-08-18 18:45:48 +02:00 committed by Alexander Medvednikov
parent 14f13ff55a
commit 38db845378
1 changed files with 5 additions and 1 deletions

View File

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