@@ -160,10 +160,19 @@ do_escape(BitString, _) when is_bitstring(BitString) ->
160
160
end ;
161
161
162
162
do_escape (Map , Q ) when is_map (Map ) ->
163
- TT = do_quote (lists :sort (maps :to_list (Map )), Q ),
163
+ TT =
164
+ [if
165
+ is_reference (V ) ->
166
+ argument_error (<<('Elixir.Kernel' :inspect (Map , []))/binary , " contains a reference (" ,
167
+ ('Elixir.Kernel' :inspect (V , []))/binary , " ) and therefore it cannot be escaped " ,
168
+ " (it must be defined within a function instead). " , (bad_escape_hint ())/binary >>);
169
+ true ->
170
+ {do_quote (K , Q ), do_quote (V , Q )}
171
+ end || {K , V } <- lists :sort (maps :to_list (Map ))],
164
172
{'%{}' , [], TT };
165
173
166
- do_escape ([], _ ) -> [];
174
+ do_escape ([], _ ) ->
175
+ [];
167
176
168
177
do_escape ([H | T ], # elixir_quote {unquote = false } = Q ) ->
169
178
do_quote_simple_list (T , do_quote (H , Q ), Q );
@@ -195,8 +204,11 @@ do_escape(Other, _) ->
195
204
196
205
bad_escape (Arg ) ->
197
206
argument_error (<<" cannot escape " , ('Elixir.Kernel' :inspect (Arg , []))/binary , " . " ,
198
- " The supported values are: lists, tuples, maps, atoms, numbers, bitstrings, " ,
199
- " PIDs and remote functions in the format &Mod.fun/arity" >>).
207
+ (bad_escape_hint ())/binary >>).
208
+
209
+ bad_escape_hint () ->
210
+ <<" The supported values are: lists, tuples, maps, atoms, numbers, bitstrings, " ,
211
+ " PIDs and remote functions in the format &Mod.fun/arity" >>.
200
212
201
213
% % Quote entry points
202
214
0 commit comments