diff --git a/lib/archethic/contracts/interpreter/ast_helper.ex b/lib/archethic/contracts/interpreter/ast_helper.ex index b3485851e..b15bcdb1c 100644 --- a/lib/archethic/contracts/interpreter/ast_helper.ex +++ b/lib/archethic/contracts/interpreter/ast_helper.ex @@ -135,7 +135,7 @@ defmodule Archethic.Contracts.Interpreter.ASTHelper do """ @spec is_function_call?(Macro.t()) :: boolean() def is_function_call?({{:atom, _}, _, list}) when is_list(list), do: true - def is_function_call?({{:., _, [{:__aliases__, _, [_]}, _]}, _, _}), do: true + def is_function_call?({{:., _, [{:__aliases__, _, _}, _]}, _, _}), do: true def is_function_call?(_), do: false @doc """ diff --git a/test/archethic/contracts/interpreter/action_interpreter_test.exs b/test/archethic/contracts/interpreter/action_interpreter_test.exs index baf881649..dde7adcee 100644 --- a/test/archethic/contracts/interpreter/action_interpreter_test.exs +++ b/test/archethic/contracts/interpreter/action_interpreter_test.exs @@ -238,6 +238,21 @@ defmodule Archethic.Contracts.Interpreter.ActionInterpreterTest do |> ActionInterpreter.parse() end + test "should be able to use a function call as a parameter to a lib function" do + code = ~S""" + actions triggered_by: transaction do + count = List.size(Contract.get_calls()) + Contract.set_content(count) + end + """ + + assert {:ok, :transaction, _} = + code + |> Interpreter.sanitize_code() + |> elem(1) + |> ActionInterpreter.parse() + end + test "should not be able to use wrong types in contract functions" do code = ~S""" actions triggered_by: transaction do