From e627eb433bfb98c3a02f9d960977652e7fd42297 Mon Sep 17 00:00:00 2001 From: Felipe Pena Date: Fri, 27 Sep 2024 08:42:25 -0300 Subject: [PATCH] fix --- vlib/v/gen/c/fn.v | 5 +++ .../v/tests/fns/iface_method_fixed_arr_test.v | 41 +++++++++++++++++++ 2 files changed, 46 insertions(+) create mode 100644 vlib/v/tests/fns/iface_method_fixed_arr_test.v diff --git a/vlib/v/gen/c/fn.v b/vlib/v/gen/c/fn.v index fdd4c75624abb8..74cfb65ee3ed53 100644 --- a/vlib/v/gen/c/fn.v +++ b/vlib/v/gen/c/fn.v @@ -1563,6 +1563,11 @@ fn (mut g Gen) method_call(node ast.CallExpr) { g.call_args(node) } g.write(')') + if !node.return_type.has_option_or_result() { + if g.table.final_sym(node.return_type).kind == .array_fixed { + g.write('.ret_arr') + } + } return } left_sym := g.table.sym(left_type) diff --git a/vlib/v/tests/fns/iface_method_fixed_arr_test.v b/vlib/v/tests/fns/iface_method_fixed_arr_test.v new file mode 100644 index 00000000000000..99f9c2974da789 --- /dev/null +++ b/vlib/v/tests/fns/iface_method_fixed_arr_test.v @@ -0,0 +1,41 @@ +module main + +pub type Mat4 = [16]f32 + +pub fn (a Mat4) * (b Mat4) Mat4 { + mut res := Mat4{} + for i := 0; i < 4; i++ { + for j := 0; j < 4; j++ { + res[j * 4 + i] = 0 + for k := 0; k < 4; k++ { + res[j * 4 + i] += a[k * 4 + i] * b[j * 4 + k] + } + } + } + return res +} + +interface IGameObject { + parent ?&IGameObject + transform Mat4 + world_transform() Mat4 +} + +struct GameObject implements IGameObject { +mut: + transform Mat4 + parent ?&IGameObject +} + +fn (gameobject GameObject) world_transform() Mat4 { + if mut p := gameobject.parent { + return p.world_transform() * gameobject.transform + } + return gameobject.transform +} + +fn test_main() { + t := GameObject{} + a := dump(t.world_transform()) + assert a.len == 16 +}