Let's say we have this module:

defmodule MyModule do
>   defguard is_some_complex_item(item) when is_struct(item) or is_atom(item)
>
>   def id(%{a: a, b: b} = item) when is_some_complex_item(a) and 
> is_some_complex_item(b) do
>     item
>   end
> end
>
 
 then invoking MyModule.id(1) produces the following error:

** (FunctionClauseError) no function clause matching in MyModule.id/1    
>     
>     The following arguments were given to MyModule.id/1:
>     
>         # 1
>         1
>     
>     Attempted function clauses (showing 1 out of 1):
>     
>         def id(%{a: a, b: b} = item) when (is_map(a) and 
> is_map_key(:__struct__, a) and is_atom(map_get(:__struct__, a)) or 
> is_atom(a)) and (is_map(b) and is_map_key(:__struct__, b) and 
> is_atom(map_get(:__struct__, b)) or is_atom(b))
>


The issue here is that internal implementation of my custom guard and even 
built-in is_struct is shown.
It is not easy to debug this kind of messages. My expectation is to see not 
expanded macro in guards.

-- 
You received this message because you are subscribed to the Google Groups 
"elixir-lang-core" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to elixir-lang-core+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/elixir-lang-core/92e14a2e-448c-44d4-b30b-00762db7204a%40googlegroups.com.

Reply via email to