Skip to content

Commit 13299af

Browse files
leosterajosevalim
authored andcommitted
Fix deprecated Dict, HashDict, and HashSet calls
Resolve the deprecated dictionary branches against Elixir.Dict rather than the absent Erlang module Dict. Use the fully qualified module names in HashDict and HashSet protocols too. Closes #15987. Assisted-by: Codex:GPT-6
1 parent 80b2291 commit 13299af

4 files changed

Lines changed: 12 additions & 12 deletions

File tree

‎lib/elixir/lib/enum.ex‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1446,7 +1446,7 @@ defmodule Enum do
14461446
)
14471447

14481448
# Avoid warnings about Dict
1449-
dict_module = String.to_unsafe_atom("Dict")
1449+
dict_module = String.to_unsafe_atom("Elixir.Dict")
14501450

14511451
reduce(reverse(enumerable), dict, fn entry, categories ->
14521452
dict_module.update(categories, fun.(entry), [entry], &[entry | &1])

‎lib/elixir/lib/hash_dict.ex‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -265,13 +265,13 @@ defimpl Enumerable, for: HashDict do
265265

266266
def reduce(dict, acc, fun) do
267267
# Avoid warnings about HashDict being deprecated.
268-
module = String.to_unsafe_atom("HashDict")
268+
module = String.to_unsafe_atom("Elixir.HashDict")
269269
module.reduce(dict, acc, fun)
270270
end
271271

272272
def member?(dict, {key, value}) do
273273
# Avoid warnings about HashDict being deprecated.
274-
module = String.to_unsafe_atom("HashDict")
274+
module = String.to_unsafe_atom("Elixir.HashDict")
275275
{:ok, match?({:ok, ^value}, module.fetch(dict, key))}
276276
end
277277

@@ -281,7 +281,7 @@ defimpl Enumerable, for: HashDict do
281281

282282
def count(dict) do
283283
# Avoid warnings about HashDict being deprecated.
284-
module = String.to_unsafe_atom("HashDict")
284+
module = String.to_unsafe_atom("Elixir.HashDict")
285285
{:ok, module.size(dict)}
286286
end
287287

@@ -296,7 +296,7 @@ defimpl Collectable, for: HashDict do
296296

297297
def into(original) do
298298
# Avoid warnings about HashDict being deprecated.
299-
module = String.to_unsafe_atom("HashDict")
299+
module = String.to_unsafe_atom("Elixir.HashDict")
300300

301301
collector_fun = fn
302302
dict, {:cont, {key, value}} -> module.put(dict, key, value)
@@ -315,7 +315,7 @@ defimpl Inspect, for: HashDict do
315315

316316
def inspect(dict, opts) do
317317
# Avoid warnings about HashDict being deprecated.
318-
module = String.to_unsafe_atom("HashDict")
318+
module = String.to_unsafe_atom("Elixir.HashDict")
319319
concat(["#HashDict<", Inspect.List.inspect(module.to_list(dict), opts), ">"])
320320
end
321321
end

‎lib/elixir/lib/hash_set.ex‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -279,19 +279,19 @@ defimpl Enumerable, for: HashSet do
279279

280280
def reduce(set, acc, fun) do
281281
# Avoid warnings about HashSet being deprecated.
282-
module = String.to_unsafe_atom("HashSet")
282+
module = String.to_unsafe_atom("Elixir.HashSet")
283283
module.reduce(set, acc, fun)
284284
end
285285

286286
def member?(set, term) do
287287
# Avoid warnings about HashSet being deprecated.
288-
module = String.to_unsafe_atom("HashSet")
288+
module = String.to_unsafe_atom("Elixir.HashSet")
289289
{:ok, module.member?(set, term)}
290290
end
291291

292292
def count(set) do
293293
# Avoid warnings about HashSet being deprecated.
294-
module = String.to_unsafe_atom("HashSet")
294+
module = String.to_unsafe_atom("Elixir.HashSet")
295295
{:ok, module.size(set)}
296296
end
297297

@@ -306,7 +306,7 @@ defimpl Collectable, for: HashSet do
306306

307307
def into(original) do
308308
# Avoid warnings about HashSet being deprecated.
309-
module = String.to_unsafe_atom("HashSet")
309+
module = String.to_unsafe_atom("Elixir.HashSet")
310310

311311
collector_fun = fn
312312
set, {:cont, term} -> module.put(set, term)
@@ -325,7 +325,7 @@ defimpl Inspect, for: HashSet do
325325

326326
def inspect(set, opts) do
327327
# Avoid warnings about HashSet being deprecated.
328-
module = String.to_unsafe_atom("HashSet")
328+
module = String.to_unsafe_atom("Elixir.HashSet")
329329
concat(["#HashSet<", Inspect.List.inspect(module.to_list(set), opts), ">"])
330330
end
331331
end

‎lib/elixir/lib/uri.ex‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,7 @@ defmodule URI do
254254

255255
{{key, value}, rest} ->
256256
# Avoid warnings about Dict being deprecated
257-
dict_module = String.to_unsafe_atom("Dict")
257+
dict_module = String.to_unsafe_atom("Elixir.Dict")
258258
decode_query_into_dict(rest, dict_module.put(dict, key, value), encoding)
259259
end
260260
end

0 commit comments

Comments
 (0)