From 3c7b0d6d05ee5dc27a9f1b4dcbcb9f5e989d567f Mon Sep 17 00:00:00 2001 From: Alexander Medvednikov Date: Sat, 7 Mar 2020 00:19:27 +0100 Subject: [PATCH] cgen: fix [] --- vlib/v/gen/cgen.v | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/vlib/v/gen/cgen.v b/vlib/v/gen/cgen.v index d16af0265e..bfcff3582a 100644 --- a/vlib/v/gen/cgen.v +++ b/vlib/v/gen/cgen.v @@ -308,9 +308,7 @@ fn (g mut Gen) gen_fn_decl(it ast.FnDecl) { } // Receiver is the first argument if it.is_method { - // styp := g.table.type_to_str(it.receiver.typ) - sym := g.table.get_type_symbol(it.receiver.typ) - styp := sym.name.replace('.', '__') + styp := g.typ(it.receiver.typ) g.write('$styp $it.receiver.name') g.definitions.write('$styp $it.receiver.name') if it.args.len > 0 { @@ -645,8 +643,12 @@ fn (g mut Gen) index_expr(node ast.IndexExpr) { g.expr(node.index) g.write(')') } - // g.write('[') - // g.write(']') + else { + g.expr(node.left) + g.write('[') + g.expr(node.index) + g.write(']') + } } }