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