From f37b9d99fe289600d5f47450f12e85c5c29d6895 Mon Sep 17 00:00:00 2001 From: Alexander Medvednikov Date: Thu, 19 Mar 2020 19:36:15 +0100 Subject: [PATCH] cgen: last/first fix --- vlib/v/gen/cgen.v | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/vlib/v/gen/cgen.v b/vlib/v/gen/cgen.v index 3835ee2719..214d3ab7ea 100644 --- a/vlib/v/gen/cgen.v +++ b/vlib/v/gen/cgen.v @@ -762,6 +762,10 @@ fn (g mut Gen) expr(node ast.Expr) { // && rec_sym.name == 'array' && receiver_name.starts_with('array') { // `array_byte_clone` => `array_clone` receiver_name = 'array' + if it.name in ['last', 'first'] { + return_type_str := g.typ(it.return_type) + g.write('*($return_type_str*)') + } } name := '${receiver_name}_$it.name'.replace('.', '__') // if it.receiver_type != 0 {