From a3d6a9349de8caae5b567703f9bc2787f8acff64 Mon Sep 17 00:00:00 2001 From: Swastik Baranwal Date: Tue, 13 Sep 2022 17:23:43 +0530 Subject: [PATCH] cgen: make go func with array type work (#15747) --- vlib/v/gen/c/fn.v | 2 +- vlib/v/tests/go_call_fn_return_test.v | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) create mode 100644 vlib/v/tests/go_call_fn_return_test.v diff --git a/vlib/v/gen/c/fn.v b/vlib/v/gen/c/fn.v index c25f7516a6..9ebbec9ef3 100644 --- a/vlib/v/gen/c/fn.v +++ b/vlib/v/gen/c/fn.v @@ -1718,7 +1718,7 @@ fn (mut g Gen) go_expr(node ast.GoExpr) { } if expr.is_method { receiver_sym := g.table.sym(expr.receiver_type) - name = receiver_sym.name + '_' + name + name = receiver_sym.cname + '_' + name } else if mut expr.left is ast.AnonFn { if expr.left.inherited_vars.len > 0 { fn_var := g.fn_var_signature(expr.left.decl.return_type, expr.left.decl.params.map(it.typ), diff --git a/vlib/v/tests/go_call_fn_return_test.v b/vlib/v/tests/go_call_fn_return_test.v new file mode 100644 index 0000000000..400a0a02a5 --- /dev/null +++ b/vlib/v/tests/go_call_fn_return_test.v @@ -0,0 +1,9 @@ +const text = 'Hello world' + +fn test_go_call_fn_return() { + hex_go := go text.bytes().hex() + hex := text.bytes().hex() + + assert hex == '48656c6c6f20776f726c64' + assert hex_go.wait() == hex +}