@@ -1795,13 +1795,15 @@ defmodule Macro do
17951795 defp do_expand_once ( { :__DIR__ , _ , atom } , env ) when is_atom ( atom ) ,
17961796 do: { :filename . dirname ( env . file ) , true }
17971797
1798- defp do_expand_once ( { :__ENV__ , _ , atom } , env ) when is_atom ( atom ) ,
1799- do: { { :%{} , [ ] , Map . to_list ( env ) } , true }
1798+ defp do_expand_once ( { :__ENV__ , _ , atom } , env ) when is_atom ( atom ) do
1799+ env = update_in ( env . versioned_vars , & maybe_escape_map / 1 )
1800+ { maybe_escape_map ( env ) , true }
1801+ end
18001802
18011803 defp do_expand_once ( { { :. , _ , [ { :__ENV__ , _ , atom } , field ] } , _ , [ ] } = original , env )
18021804 when is_atom ( atom ) and is_atom ( field ) do
18031805 if Map . has_key? ( env , field ) do
1804- { Map . get ( env , field ) , true }
1806+ { maybe_escape_map ( Map . get ( env , field ) ) , true }
18051807 else
18061808 { original , false }
18071809 end
@@ -1884,6 +1886,9 @@ defmodule Macro do
18841886 # Anything else is just returned
18851887 defp do_expand_once ( other , _env ) , do: { other , false }
18861888
1889+ defp maybe_escape_map ( map ) when is_map ( map ) , do: { :%{} , [ ] , Map . to_list ( map ) }
1890+ defp maybe_escape_map ( other ) , do: other
1891+
18871892 @ doc """
18881893 Returns `true` if the given name and arity is a special form.
18891894 """
0 commit comments