@@ -2681,11 +2681,19 @@ defmodule Kernel do
26812681 invalid_match! ( :is_struct )
26822682
26832683 :guard ->
2684- quote do
2685- is_map ( unquote ( term ) ) and
2686- ( is_atom ( unquote ( name ) ) or :fail ) and
2687- :erlang . is_map_key ( :__struct__ , unquote ( term ) ) and
2688- :erlang . map_get ( :__struct__ , unquote ( term ) ) == unquote ( name )
2684+ if is_atom ( name ) or is_atom ( Macro . expand ( name , __CALLER__ ) ) do
2685+ quote do
2686+ is_map ( unquote ( term ) ) and
2687+ :erlang . is_map_key ( :__struct__ , unquote ( term ) ) and
2688+ :erlang . map_get ( :__struct__ , unquote ( term ) ) == unquote ( name )
2689+ end
2690+ else
2691+ quote do
2692+ is_map ( unquote ( term ) ) and
2693+ ( is_atom ( unquote ( name ) ) or :fail ) and
2694+ :erlang . is_map_key ( :__struct__ , unquote ( term ) ) and
2695+ :erlang . map_get ( :__struct__ , unquote ( term ) ) == unquote ( name )
2696+ end
26892697 end
26902698 end
26912699 end
@@ -2805,13 +2813,23 @@ defmodule Kernel do
28052813 invalid_match! ( :is_exception )
28062814
28072815 :guard ->
2808- quote do
2809- is_map ( unquote ( term ) ) and
2810- ( is_atom ( unquote ( name ) ) or :fail ) and
2811- :erlang . is_map_key ( :__struct__ , unquote ( term ) ) and
2812- :erlang . map_get ( :__struct__ , unquote ( term ) ) == unquote ( name ) and
2813- :erlang . is_map_key ( :__exception__ , unquote ( term ) ) and
2814- :erlang . map_get ( :__exception__ , unquote ( term ) ) == true
2816+ if is_atom ( name ) or is_atom ( Macro . expand ( name , __CALLER__ ) ) do
2817+ quote do
2818+ is_map ( unquote ( term ) ) and
2819+ :erlang . is_map_key ( :__struct__ , unquote ( term ) ) and
2820+ :erlang . map_get ( :__struct__ , unquote ( term ) ) == unquote ( name ) and
2821+ :erlang . is_map_key ( :__exception__ , unquote ( term ) ) and
2822+ :erlang . map_get ( :__exception__ , unquote ( term ) ) == true
2823+ end
2824+ else
2825+ quote do
2826+ is_map ( unquote ( term ) ) and
2827+ ( is_atom ( unquote ( name ) ) or :fail ) and
2828+ :erlang . is_map_key ( :__struct__ , unquote ( term ) ) and
2829+ :erlang . map_get ( :__struct__ , unquote ( term ) ) == unquote ( name ) and
2830+ :erlang . is_map_key ( :__exception__ , unquote ( term ) ) and
2831+ :erlang . map_get ( :__exception__ , unquote ( term ) ) == true
2832+ end
28152833 end
28162834 end
28172835 end
0 commit comments