Skip to content

Commit

Permalink
temporary fix bug for dialyzer
Browse files Browse the repository at this point in the history
  • Loading branch information
shahryarjb committed Dec 20, 2023
1 parent 106ff32 commit 764d32f
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 11 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ erl_crash.dump
*.beam
/config/*.secret.exs
.elixir_ls/
.elixir-tools/

# General
.DS_Store
Expand All @@ -17,3 +18,6 @@ Desktop.ini
.LSOverride
.tool-versions
name

# custom
/lib/example
29 changes: 18 additions & 11 deletions lib/macros/guarded_struct.ex
Original file line number Diff line number Diff line change
Expand Up @@ -1314,22 +1314,22 @@ defmodule GuardedStruct do
quote do
def builder(attrs, error \\ false)

def builder({key, attrs, type} = input, error)
def builder({key, attrs} = input, error)
when is_tuple(input) and is_map(attrs) and (is_list(key) or is_atom(key)) do
GuardedStruct.builder(
%{attrs: attrs, module: unquote(module), revaluation: unquote(escaped_list)},
key,
type,
:add,
error
)
end

def builder({key, attrs} = input, error)
when is_tuple(input) and is_map(attrs) and is_list(key) do
def builder({key, attrs, type} = input, error)
when is_tuple(input) and is_map(attrs) and (is_list(key) or is_atom(key)) do
GuardedStruct.builder(
%{attrs: attrs, module: unquote(module), revaluation: unquote(escaped_list)},
key,
:add,
type,
error
)
end
Expand Down Expand Up @@ -1375,7 +1375,7 @@ defmodule GuardedStruct do
info = unquote(List.last(escaped_list) |> List.first())

path =
if(info.key == :root,
if(Map.get(info, :key) == :root,
do: [],
else:
info.module
Expand Down Expand Up @@ -1553,11 +1553,16 @@ defmodule GuardedStruct do
end

@spec builder(
%{:attrs => any(), :module => any(), :revaluation => list(), optional(any()) => any()},
:root | [atom()],
%{
:attrs => map(),
:module => module(),
:revaluation => list(),
optional(any()) => any()
},
:root | list(atom()),
:add | :edit,
any()
) :: {:ok, any()} | {:error, any(), any()}
boolean()
) :: {:ok, map() | list(map())} | {:error, any(), any()}
@doc false
def builder(actions, key, type, error \\ false) do
%{attrs: attrs, module: module, revaluation: [h | t]} = actions
Expand Down Expand Up @@ -2670,7 +2675,9 @@ defmodule GuardedStruct do
end)
end

@spec conditional_fields_validating_pattern({any(), atom(), list(any()), map() | list(), atom(), :add | :edit, boolean()}) ::
@spec conditional_fields_validating_pattern(
{any(), atom(), list(any()), map() | list(), atom(), :add | :edit, boolean()}
) ::
list() | {any(), list(), any()}
def conditional_fields_validating_pattern(
{cond_data, field, list_values, full_attrs, key, type, true}
Expand Down

0 comments on commit 764d32f

Please sign in to comment.