From 38db845378441d69e8b674c1d25e9ece00434e58 Mon Sep 17 00:00:00 2001 From: Henrixounez Date: Sun, 18 Aug 2019 18:45:48 +0200 Subject: [PATCH] compiler: auto dereference mutable variable upon return --- compiler/parser.v | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/compiler/parser.v b/compiler/parser.v index 58c4885a4b..6778669298 100644 --- a/compiler/parser.v +++ b/compiler/parser.v @@ -3352,7 +3352,11 @@ fn (p mut Parser) return_st() { } if total_text == '' || expr_type == 'void*' { - p.cgen.resetln('return $ret') + 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')