formular icon indicating copy to clipboard operation
formular copied to clipboard

Deprecation warning

Open a-maze-d opened this issue 1 year ago • 0 comments

This line is responsible for a deprecation warning when using Tablex

warning: :functions option in eval is deprecated
  (elixir 1.15.7) src/elixir.erl:294: :elixir.env_for_eval/1
  (elixir 1.15.7) lib/code.ex:998: Code.eval_quoted/3
  (formular 0.4.1) lib/formular.ex:354: Formular.do_eval/3
  (tablex 0.3.1) lib/tablex/decider.ex:193: anonymous fn/3 in Tablex.Decider.maybe_exec_code/3
  (elixir 1.15.7) lib/map.ex:257: Map.do_map/2
  (elixir 1.15.7) lib/map.ex:251: Map.new_from_map/2

This can easily be fixed by changing the code to look like the following:

 defp do_eval(ast, binding, context) do
    {ret, _binding} =
      ast
      |> Code.eval_quoted(
        binding,
        %Macro.Env{
          functions: imported_functions(context),
          macros: imported_macros(context),
          requires: [Elixir.Kernel]
        }
      )

    {:ok, ret}
  rescue
    err ->
      {:error, err}
  end

I.e. make use of the Macro.Env structure instead.

a-maze-d avatar Sep 12 '24 20:09 a-maze-d