Skip to content

Commit

Permalink
Fix compilation on Elixir < v1.14.2
Browse files Browse the repository at this point in the history
  • Loading branch information
jonatanklosko committed Nov 8, 2022
1 parent 6f522a2 commit 97540fb
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion lib/livebook/runtime/evaluator.ex
Original file line number Diff line number Diff line change
Expand Up @@ -528,7 +528,15 @@ defmodule Livebook.Runtime.Evaluator do
defp eval(code, binding, env) do
try do
quoted = Code.string_to_quoted!(code, file: env.file)
{value, binding, env} = Code.eval_quoted_with_env(quoted, binding, env, prune_binding: true)

# TODO: remove the else branch when we require Elixir v1.14.2
{value, binding, env} =
if function_exported?(Code, :eval_quoted_with_env, 4) do
Code.eval_quoted_with_env(quoted, binding, env, prune_binding: true)
else
Code.eval_quoted_with_env(quoted, binding, env)
end

{:ok, value, binding, env}
catch
kind, error ->
Expand Down

0 comments on commit 97540fb

Please sign in to comment.