From ae05f35105bdfe35a4c3a8c72128cde7a1b388ea Mon Sep 17 00:00:00 2001 From: Vadim Tsvetkov Date: Sun, 19 Jun 2022 02:26:44 +0300 Subject: [PATCH] Fix witchcrafters/algae#75 --- lib/algae/internal.ex | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/lib/algae/internal.ex b/lib/algae/internal.ex index 670bf30..e2296cd 100644 --- a/lib/algae/internal.ex +++ b/lib/algae/internal.ex @@ -251,11 +251,19 @@ defmodule Algae.Internal do def default_value({{:., _, [String, :t]}, _, _}), do: "" def default_value({{:., _, [{_, _, adt}, :t]}, _, []}) do - quote do: unquote(Module.concat(adt)).new() + if Kernel.function_exported?(Module.concat(adt), :new, 0) do + quote do: unquote(Module.concat(adt)).new() + else + quote do: nil + end end def default_value({{:., _, [module, :t]}, _, []}) do - quote do: unquote(module).new() + if Kernel.function_exported?(module, :new, 0) do + quote do: unquote(module).new() + else + quote do: nil + end end def default_value([_]), do: []