diff --git a/lib/eex/lib/eex/engine.ex b/lib/eex/lib/eex/engine.ex index 12234f048c8..f17c211cb3b 100644 --- a/lib/eex/lib/eex/engine.ex +++ b/lib/eex/lib/eex/engine.ex @@ -195,7 +195,7 @@ defmodule EEx.Engine do def handle_expr(state, "=", ast) do check_state!(state) %{binary: binary, dynamic: dynamic, vars_count: vars_count} = state - var = Macro.var(:"arg#{vars_count}", __MODULE__) + var = Macro.var(String.to_unsafe_atom("arg#{vars_count}"), __MODULE__) ast = quote do diff --git a/lib/elixir/lib/base.ex b/lib/elixir/lib/base.ex index 35016ab7e4a..4847a12238c 100644 --- a/lib/elixir/lib/base.ex +++ b/lib/elixir/lib/base.ex @@ -436,7 +436,7 @@ defmodule Base do end for {base, alphabet} <- [upper: b16_alphabet, lower: to_lower_enc.(b16_alphabet)] do - name = :"encode16#{base}" + name = String.to_unsafe_atom("encode16#{base}") encoded = to_encode_list.(alphabet) @compile {:inline, [{name, 1}]} @@ -617,10 +617,10 @@ defmodule Base do upper = Enum.with_index(b16_alphabet) for {base, alphabet} <- [upper: upper, lower: to_lower_dec.(upper), mixed: to_mixed_dec.(upper)] do - decode_name = :"decode16#{base}!" - validate_name = :"validate16#{base}?" - valid_char_name = :"valid_char16#{base}?" - valid_word_name = :"valid_word16#{base}?" + decode_name = String.to_unsafe_atom("decode16#{base}!") + validate_name = String.to_unsafe_atom("validate16#{base}?") + valid_char_name = String.to_unsafe_atom("valid_char16#{base}?") + valid_word_name = String.to_unsafe_atom("valid_word16#{base}?") {min, decoded} = to_decode_list.(alphabet) @@ -735,7 +735,7 @@ defmodule Base do end for {base, alphabet} <- [base: b64_alphabet, url: b64url_alphabet] do - name = :"encode64#{base}" + name = String.to_unsafe_atom("encode64#{base}") encoded = to_encode_list.(alphabet) @compile {:inline, [{name, 1}]} @@ -1001,12 +1001,12 @@ defmodule Base do end for {base, alphabet} <- [base: b64_alphabet, url: b64url_alphabet] do - decode_name = :"decode64#{base}!" + decode_name = String.to_unsafe_atom("decode64#{base}!") - validate_name = :"validate64#{base}?" - validate_main_name = :"validate_main64#{validate_name}?" - valid_char_name = :"valid_char64#{base}?" - valid_word_name = :"valid_word64#{base}?" + validate_name = String.to_unsafe_atom("validate64#{base}?") + validate_main_name = String.to_unsafe_atom("validate_main64#{validate_name}?") + valid_char_name = String.to_unsafe_atom("valid_char64#{base}?") + valid_word_name = String.to_unsafe_atom("valid_word64#{base}?") {min, decoded} = alphabet |> Enum.with_index() |> to_decode_list.() # SWAR fast path: 7 bytes per stride, validated via `valid_word64?` @@ -1314,7 +1314,7 @@ defmodule Base do hexupper: b32hex_alphabet, hexlower: to_lower_enc.(b32hex_alphabet) ] do - name = :"encode32#{base}" + name = String.to_unsafe_atom("encode32#{base}") encoded = to_encode_list.(alphabet) @compile {:inline, [{name, 1}]} @@ -1653,16 +1653,16 @@ defmodule Base do hexlower: to_lower_dec.(hexupper), hexmixed: to_mixed_dec.(hexupper) ] do - decode_name = :"decode32#{base}!" - validate_name = :"validate32#{base}?" - validate_main_name = :"validate_main32#{validate_name}?" - valid_char_name = :"valid_char32#{base}?" + decode_name = String.to_unsafe_atom("decode32#{base}!") + validate_name = String.to_unsafe_atom("validate32#{base}?") + validate_main_name = String.to_unsafe_atom("validate_main32#{validate_name}?") + valid_char_name = String.to_unsafe_atom("valid_char32#{base}?") {min, decoded} = to_decode_list.(alphabet) # SWAR fast path: 7 bytes per stride, validated via `valid_word32?` # in the body. Tail leftover (1-6 bytes after a 7-byte stride hits an # 8-byte-multiple `main`) recurses through the single-byte clause. - valid_word_name = :"valid_word32#{base}?" + valid_word_name = String.to_unsafe_atom("valid_word32#{base}?") defp unquote(validate_main_name)(<>), do: unquote(valid_word_name)(w) and unquote(validate_main_name)(rest) diff --git a/lib/elixir/lib/code.ex b/lib/elixir/lib/code.ex index 97c5931c88d..bca3c20cf20 100644 --- a/lib/elixir/lib/code.ex +++ b/lib/elixir/lib/code.ex @@ -767,6 +767,12 @@ defmodule Code do * `:migrate` (since v1.18.0) - when `true`, sets all other migration options to `true` by default. Defaults to `false`. + * `:migrate_atom_interpolations` (since v1.21.0) - when `true`, rewrites + deprecated atom interpolations to explicit calls to `String.to_unsafe_atom/1`. + For example, `:"foo_#{bar}"` becomes `String.to_unsafe_atom("foo_#{bar}")` + and `["foo_#{bar}": 1]` becomes `[{String.to_unsafe_atom("foo_#{bar}"), 1}]`. + Defaults to the value of the `:migrate` option. This option changes the AST. + * `:migrate_bitstring_modifiers` (since v1.18.0) - when `true`, removes unnecessary parentheses in known bitstring [modifiers](`<<>>/1`), for example `<>` diff --git a/lib/elixir/lib/code/formatter.ex b/lib/elixir/lib/code/formatter.ex index b6320d199db..11dc9675fe4 100644 --- a/lib/elixir/lib/code/formatter.ex +++ b/lib/elixir/lib/code/formatter.ex @@ -195,6 +195,7 @@ defmodule Code.Formatter do file = Keyword.get(opts, :file, nil) sigils = Keyword.get(opts, :sigils, []) migrate = Keyword.get(opts, :migrate, false) + migrate_atom_interpolations = Keyword.get(opts, :migrate_atom_interpolations, migrate) migrate_bitstring_modifiers = Keyword.get(opts, :migrate_bitstring_modifiers, migrate) migrate_call_parens_on_pipe = Keyword.get(opts, :migrate_call_parens_on_pipe, migrate) migrate_charlists_as_sigils = Keyword.get(opts, :migrate_charlists_as_sigils, migrate) @@ -223,6 +224,7 @@ defmodule Code.Formatter do comments: comments, sigils: sigils, file: file, + migrate_atom_interpolations: migrate_atom_interpolations, migrate_bitstring_modifiers: migrate_bitstring_modifiers, migrate_call_parens_on_pipe: migrate_call_parens_on_pipe, migrate_charlists_as_sigils: migrate_charlists_as_sigils, @@ -334,14 +336,20 @@ defmodule Code.Formatter do end defp quoted_to_algebra( - {{:., _, [:erlang, :binary_to_atom]}, _, [{:<<>>, _, entries}, :utf8]} = quoted, + {{:., _, [:erlang, :binary_to_atom]}, _, [{:<<>>, _, entries} = bitstring, :utf8]} = + quoted, context, state ) do - if interpolated?(entries) do - interpolation_to_algebra(entries, @double_quote, state, ":\"", @double_quote) - else - remote_to_algebra(quoted, context, state) + cond do + not interpolated?(entries) -> + remote_to_algebra(quoted, context, state) + + state.migrate_atom_interpolations -> + quoted_to_algebra(quote(do: String.to_unsafe_atom(unquote(bitstring))), context, state) + + true -> + interpolation_to_algebra(entries, @double_quote, state, ":\"", @double_quote) end end diff --git a/lib/elixir/lib/io/ansi.ex b/lib/elixir/lib/io/ansi.ex index d8e49d0a95b..b12ea3e3e36 100644 --- a/lib/elixir/lib/io/ansi.ex +++ b/lib/elixir/lib/io/ansi.ex @@ -159,7 +159,7 @@ defmodule IO.ANSI do for font_n <- [1, 2, 3, 4, 5, 6, 7, 8, 9] do @doc "Sets alternative font #{font_n}." - defsequence.(:"font_#{font_n}", font_n + 10, "m") + defsequence.(String.to_unsafe_atom("font_#{font_n}"), font_n + 10, "m") end @doc "Normal color or intensity." @@ -193,13 +193,13 @@ defmodule IO.ANSI do defsequence.(color, code + 30, "m") @doc "Sets foreground color to light #{color}." - defsequence.(:"light_#{color}", code + 90, "m") + defsequence.(String.to_unsafe_atom("light_#{color}"), code + 90, "m") @doc "Sets background color to #{color}." - defsequence.(:"#{color}_background", code + 40, "m") + defsequence.(String.to_unsafe_atom("#{color}_background"), code + 40, "m") @doc "Sets background color to light #{color}." - defsequence.(:"light_#{color}_background", code + 100, "m") + defsequence.(String.to_unsafe_atom("light_#{color}_background"), code + 100, "m") end @doc "Default text color." diff --git a/lib/elixir/lib/macro/env.ex b/lib/elixir/lib/macro/env.ex index 5ec87336e7d..a7651dd460b 100644 --- a/lib/elixir/lib/macro/env.ex +++ b/lib/elixir/lib/macro/env.ex @@ -213,13 +213,13 @@ defmodule Macro.Env do @doc false @deprecated "Use Macro.Env.expand_alias/4 instead" def fetch_alias(%{__struct__: Macro.Env, aliases: aliases}, atom) when is_atom(atom), - do: Keyword.fetch(aliases, :"Elixir.#{atom}") + do: Keyword.fetch(aliases, String.to_unsafe_atom("Elixir.#{atom}")) @doc false @deprecated "Use Macro.Env.expand_alias/4 instead" def fetch_macro_alias(%{__struct__: Macro.Env, macro_aliases: aliases}, atom) when is_atom(atom), - do: Keyword.fetch(aliases, :"Elixir.#{atom}") + do: Keyword.fetch(aliases, String.to_unsafe_atom("Elixir.#{atom}")) @doc """ Returns the modules from which the given `{name, arity}` was diff --git a/lib/elixir/lib/module.ex b/lib/elixir/lib/module.ex index 6af24400741..e7c9f37d028 100644 --- a/lib/elixir/lib/module.ex +++ b/lib/elixir/lib/module.ex @@ -1192,7 +1192,7 @@ defmodule Module do defp expand_key(key, counters) do case counters do %{^key => count} when is_integer(count) and count >= 1 -> - {{:"#{key}#{count}", [], Elixir}, Map.put(counters, key, count - 1)} + {{String.to_unsafe_atom("#{key}#{count}"), [], Elixir}, Map.put(counters, key, count - 1)} _ -> {{key, [], Elixir}, counters} @@ -1225,7 +1225,8 @@ defmodule Module do defp merge_signature({var, _, _} = older, {var, _, _}, _), do: older # Otherwise, returns a generic guess - defp merge_signature({_, meta, _}, _newer, i), do: {:"arg#{i}", meta, Elixir} + defp merge_signature({_, meta, _}, _newer, i), + do: {String.to_unsafe_atom("arg#{i}"), meta, Elixir} @doc """ Checks if the module defines the given function or macro. diff --git a/lib/elixir/test/elixir/file/stream_test.exs b/lib/elixir/test/elixir/file/stream_test.exs index 98df2313515..ecfef55ee21 100644 --- a/lib/elixir/test/elixir/file/stream_test.exs +++ b/lib/elixir/test/elixir/file/stream_test.exs @@ -21,7 +21,8 @@ defmodule File.StreamTest do :erpc.call(node, File, :stream!, [src, modes, lines_or_bytes]) end - distributed_node = :"secondary@#{node() |> Atom.to_string() |> :binary.split("@") |> tl()}" + distributed_node = + String.to_unsafe_atom("secondary@#{node() |> Atom.to_string() |> :binary.split("@") |> tl()}") for {type, node} <- [local: node(), distributed: distributed_node] do describe "#{type} node" do diff --git a/lib/elixir/test/elixir/module/types/descr_test.exs b/lib/elixir/test/elixir/module/types/descr_test.exs index a79b2aa956c..f1340e357fa 100644 --- a/lib/elixir/test/elixir/module/types/descr_test.exs +++ b/lib/elixir/test/elixir/module/types/descr_test.exs @@ -33,8 +33,8 @@ defmodule Module.Types.DescrTest do opt_difference( acc, open_map([ - {:k, open_map([{:"value#{index}", integer()}])}, - {:"field#{index}", integer()} + {:k, open_map([{String.to_unsafe_atom("value#{index}"), integer()}])}, + {String.to_unsafe_atom("field#{index}"), integer()} ]) ) end) @@ -45,7 +45,7 @@ defmodule Module.Types.DescrTest do opt_difference( acc, open_tuple([ - open_tuple([atom([:"value#{index}"])]), + open_tuple([atom([String.to_unsafe_atom("value#{index}")])]), integer() ]) ) @@ -3954,7 +3954,10 @@ defmodule Module.Types.DescrTest do tuple([atom([:font_style]), atom([:italic])]), Enum.reduce( for elem1 <- 1..5, elem2 <- 1..5 do - tuple([atom([:"f#{elem1}"]), atom([:"s#{elem2}"])]) + tuple([ + atom([String.to_unsafe_atom("f#{elem1}")]), + atom([String.to_unsafe_atom("s#{elem2}")]) + ]) end, &opt_union/2 ) @@ -4008,7 +4011,7 @@ defmodule Module.Types.DescrTest do {:notifications, boolean()} ] ++ Enum.map(1..50, fn i -> - {:"field_#{i}", atom([:"value_#{i}"])} + {String.to_unsafe_atom("field_#{i}"), atom([String.to_unsafe_atom("value_#{i}")])} end) ) @@ -4021,7 +4024,7 @@ defmodule Module.Types.DescrTest do expected = for i <- 1..50 do - name = :"name_#{i}" + name = String.to_unsafe_atom("name_#{i}") closed_map([__struct__: atom([name])] ++ [{name, binary()}]) end |> Enum.reduce(&opt_union/2) diff --git a/lib/elixir/test/elixir/registry/duplicate_test.exs b/lib/elixir/test/elixir/registry/duplicate_test.exs index 87325fc4a5b..f6ee1e9f090 100644 --- a/lib/elixir/test/elixir/registry/duplicate_test.exs +++ b/lib/elixir/test/elixir/registry/duplicate_test.exs @@ -19,9 +19,10 @@ defmodule Registry.DuplicateTest do partitions = config.partitions listeners = - List.wrap(config[:base_listener]) |> Enum.map(&:"#{&1}_#{partitions}_#{inspect(keys)}") + List.wrap(config[:base_listener]) + |> Enum.map(&String.to_unsafe_atom("#{&1}_#{partitions}_#{inspect(keys)}")) - name = :"#{config.test}_#{partitions}_#{inspect(keys)}" + name = String.to_unsafe_atom("#{config.test}_#{partitions}_#{inspect(keys)}") opts = [keys: config.keys, name: name, partitions: partitions, listeners: listeners] {:ok, _} = start_supervised({Registry, opts}) %{registry: name, listeners: listeners} @@ -476,7 +477,7 @@ defmodule Registry.DuplicateTest do end test "rejects invalid tuple syntax", %{partitions: partitions} do - name = :"test_invalid_tuple_#{partitions}" + name = String.to_unsafe_atom("test_invalid_tuple_#{partitions}") assert_raise ArgumentError, ~r/expected :keys to be given and be one of/, fn -> Registry.start_link(keys: {:duplicate, :invalid}, name: name, partitions: partitions) diff --git a/lib/elixir/test/elixir/registry/unique_test.exs b/lib/elixir/test/elixir/registry/unique_test.exs index 1ef16e57dce..ec3d3bb7e05 100644 --- a/lib/elixir/test/elixir/registry/unique_test.exs +++ b/lib/elixir/test/elixir/registry/unique_test.exs @@ -16,8 +16,11 @@ defmodule Registry.UniqueTest do setup config do partitions = config.partitions - listeners = List.wrap(config[:base_listener]) |> Enum.map(&:"#{&1}_#{partitions}") - name = :"#{config.test}_#{partitions}" + + listeners = + List.wrap(config[:base_listener]) |> Enum.map(&String.to_unsafe_atom("#{&1}_#{partitions}")) + + name = String.to_unsafe_atom("#{config.test}_#{partitions}") opts = [keys: @keys, name: name, partitions: partitions, listeners: listeners] {:ok, _} = start_supervised({Registry, opts}) %{registry: name, listeners: listeners} diff --git a/lib/elixir/test/elixir/registry_test.exs b/lib/elixir/test/elixir/registry_test.exs index 71129cd4c7f..879980c2c72 100644 --- a/lib/elixir/test/elixir/registry_test.exs +++ b/lib/elixir/test/elixir/registry_test.exs @@ -24,9 +24,10 @@ defmodule Registry.Test do partitions = config.partitions listeners = - List.wrap(config[:base_listener]) |> Enum.map(&:"#{&1}_#{partitions}_#{inspect(keys)}") + List.wrap(config[:base_listener]) + |> Enum.map(&String.to_unsafe_atom("#{&1}_#{partitions}_#{inspect(keys)}")) - name = :"#{config.test}_#{partitions}_#{inspect(keys)}" + name = String.to_unsafe_atom("#{config.test}_#{partitions}_#{inspect(keys)}") opts = [keys: keys, name: name, partitions: partitions, listeners: listeners] {:ok, _} = start_supervised({Registry, opts}) %{registry: name, listeners: listeners} @@ -95,7 +96,7 @@ defmodule Registry.LockTest do setup config do keys = config.keys partitions = config.partitions - name = :"#{config.test}_#{keys}_#{partitions}" + name = String.to_unsafe_atom("#{config.test}_#{keys}_#{partitions}") opts = [keys: keys, name: name, partitions: partitions] {:ok, _} = start_supervised({Registry, opts}) %{registry: name} diff --git a/lib/elixir/test/elixir/typespec_test.exs b/lib/elixir/test/elixir/typespec_test.exs index 498099167c1..dd8705bb57b 100644 --- a/lib/elixir/test/elixir/typespec_test.exs +++ b/lib/elixir/test/elixir/typespec_test.exs @@ -532,7 +532,7 @@ defmodule TypespecTest do assert {:type, _, :map_field_exact, [{:atom, _, :message}, {:type, _, :term, []}]} = arg2 end - @fields Enum.map(10..42, &{:"f#{&1}", :ok}) + @fields Enum.map(10..42, &{String.to_unsafe_atom("f#{&1}"), :ok}) test "@type with a large struct" do bytecode = diff --git a/lib/elixir/test/elixir/uri_test.exs b/lib/elixir/test/elixir/uri_test.exs index 0c58db61efd..678baddbe13 100644 --- a/lib/elixir/test/elixir/uri_test.exs +++ b/lib/elixir/test/elixir/uri_test.exs @@ -464,8 +464,8 @@ defmodule URITest do end test "base without host" do - assert URI.merge("tag:example", "foo") |> to_string == "tag:foo" - assert URI.merge("tag:example", "#fragment") |> to_string == "tag:example#fragment" + assert URI.merge("tag:example", "foo") |> to_string() == "tag:foo" + assert URI.merge("tag:example", "#fragment") |> to_string() == "tag:example#fragment" end test "base without host and path" do diff --git a/lib/ex_unit/lib/ex_unit/assertions.ex b/lib/ex_unit/lib/ex_unit/assertions.ex index d6dc5ee7fda..c996852960a 100644 --- a/lib/ex_unit/lib/ex_unit/assertions.ex +++ b/lib/ex_unit/lib/ex_unit/assertions.ex @@ -361,7 +361,7 @@ defmodule ExUnit.Assertions do case Macro.expand_once(expr, env) do ^expr when not reserved? and not all_quoted_literals? -> - vars = for i <- 1..arity, do: Macro.var(:"arg#{i}", __MODULE__) + vars = for i <- 1..arity, do: Macro.var(String.to_unsafe_atom("arg#{i}"), __MODULE__) quoted = quote do diff --git a/lib/ex_unit/lib/ex_unit/callbacks.ex b/lib/ex_unit/lib/ex_unit/callbacks.ex index 02a5e51a5f6..5c116c7a8fc 100644 --- a/lib/ex_unit/lib/ex_unit/callbacks.ex +++ b/lib/ex_unit/lib/ex_unit/callbacks.ex @@ -291,8 +291,11 @@ defmodule ExUnit.Callbacks do name = case Module.get_attribute(module, :ex_unit_describe) do - {_line, _message, counter} -> :"__ex_unit_setup_#{counter}_#{length(setup)}" - nil -> :"__ex_unit_setup_#{length(setup)}" + {_line, _message, counter} -> + String.to_unsafe_atom("__ex_unit_setup_#{counter}_#{length(setup)}") + + nil -> + String.to_unsafe_atom("__ex_unit_setup_#{length(setup)}") end Module.put_attribute(module, :ex_unit_setup, [name | setup]) @@ -425,7 +428,7 @@ defmodule ExUnit.Callbacks do def __setup_all__(module) do no_describe!(module) setup_all = Module.get_attribute(module, :ex_unit_setup_all) - name = :"__ex_unit_setup_all_#{length(setup_all)}" + name = String.to_unsafe_atom("__ex_unit_setup_all_#{length(setup_all)}") Module.put_attribute(module, :ex_unit_setup_all, [name | setup_all]) name end @@ -828,7 +831,8 @@ defmodule ExUnit.Callbacks do {nil, nil} callbacks -> - {:"__ex_unit_describe_#{map_size(used_describes)}", compile_setup(callbacks, :setup)} + {String.to_unsafe_atom("__ex_unit_describe_#{map_size(used_describes)}"), + compile_setup(callbacks, :setup)} end used_describes = Map.put(used_describes, message, name) diff --git a/lib/ex_unit/test/ex_unit/failures_manifest_test.exs b/lib/ex_unit/test/ex_unit/failures_manifest_test.exs index 06808d2f77c..219f723d36a 100644 --- a/lib/ex_unit/test/ex_unit/failures_manifest_test.exs +++ b/lib/ex_unit/test/ex_unit/failures_manifest_test.exs @@ -205,7 +205,7 @@ defmodule ExUnit.FailuresManifestTest do %ExUnit.Test{ state: state, module: SomeMod, - name: :"test #{System.unique_integer()}", + name: String.to_unsafe_atom("test #{System.unique_integer()}"), tags: %{file: file} } end diff --git a/lib/mix/lib/mix/dep/converger.ex b/lib/mix/lib/mix/dep/converger.ex index 1d7b0deade3..98accde6fab 100644 --- a/lib/mix/lib/mix/dep/converger.ex +++ b/lib/mix/lib/mix/dep/converger.ex @@ -346,11 +346,11 @@ defmodule Mix.Dep.Converger do {:ok, value} -> case List.wrap(value) -- List.wrap(other_value) do [] -> other - _ -> %{other | status: {:"diverged#{key}", dep}} + _ -> %{other | status: {String.to_unsafe_atom("diverged#{key}"), dep}} end :error -> - %{other | status: {:"diverged#{key}", dep}} + %{other | status: {String.to_unsafe_atom("diverged#{key}"), dep}} end :error -> diff --git a/lib/mix/lib/mix/generator.ex b/lib/mix/lib/mix/generator.ex index e04e4ca30dd..bbe2d0f18b8 100644 --- a/lib/mix/lib/mix/generator.ex +++ b/lib/mix/lib/mix/generator.ex @@ -216,7 +216,10 @@ defmodule Mix.Generator do require EEx source = "<% _ = assigns %>" <> contents - EEx.function_from_string(:defp, :"#{name}_template", source, [:assigns]) + + EEx.function_from_string(:defp, String.to_unsafe_atom("#{name}_template"), source, [ + :assigns + ]) end end @@ -243,7 +246,7 @@ defmodule Mix.Generator do _ -> raise ArgumentError, "expected string or from_file: file" end - defp unquote(:"#{name}_text")(), do: unquote(contents) + defp unquote(String.to_unsafe_atom("#{name}_text"))(), do: unquote(contents) end end end diff --git a/lib/mix/lib/mix/task.ex b/lib/mix/lib/mix/task.ex index d336ba639cd..72d7d112e26 100644 --- a/lib/mix/lib/mix/task.ex +++ b/lib/mix/lib/mix/task.ex @@ -188,7 +188,7 @@ defmodule Mix.Task do case base do <<"Elixir.Mix.Tasks.", rest::binary-size(^part), ".beam">> -> - mod = :"Elixir.Mix.Tasks.#{rest}" + mod = String.to_unsafe_atom("Elixir.Mix.Tasks.#{rest}") ensure_task?(mod) && mod _ -> diff --git a/lib/mix/lib/mix/tasks/archive.install.ex b/lib/mix/lib/mix/tasks/archive.install.ex index de27e5d9d83..13814c64f95 100644 --- a/lib/mix/lib/mix/tasks/archive.install.ex +++ b/lib/mix/lib/mix/tasks/archive.install.ex @@ -176,7 +176,7 @@ defmodule Mix.Tasks.Archive.Install do type = elem(file_info, 2) path = zip_path_to_string(path) - unless type in [:regular, :directory] do + if type not in [:regular, :directory] do Mix.raise( "Installation failed: invalid archive file, #{inspect(path)} is not a regular file or directory" ) diff --git a/lib/mix/lib/mix/tasks/deps.clean.ex b/lib/mix/lib/mix/tasks/deps.clean.ex index 5e59334c80a..9ee1470fff9 100644 --- a/lib/mix/lib/mix/tasks/deps.clean.ex +++ b/lib/mix/lib/mix/tasks/deps.clean.ex @@ -43,7 +43,7 @@ defmodule Mix.Tasks.Deps.Clean do loaded_opts = for {switch, key} <- [only: :env, target: :target], value = opts[switch], - do: {key, :"#{value}"} + do: {key, String.to_unsafe_atom("#{value}")} loaded_deps = Mix.Dep.Converger.converge(loaded_opts) diff --git a/lib/mix/lib/mix/tasks/deps.get.ex b/lib/mix/lib/mix/tasks/deps.get.ex index c57b53dad16..5d96ea6f493 100644 --- a/lib/mix/lib/mix/tasks/deps.get.ex +++ b/lib/mix/lib/mix/tasks/deps.get.ex @@ -38,7 +38,7 @@ defmodule Mix.Tasks.Deps.Get do fetch_opts = for {switch, key} <- [only: :env, target: :target, check_locked: :check_locked], value = opts[switch], - do: {key, :"#{value}"} + do: {key, String.to_unsafe_atom("#{value}")} apps = Mix.Dep.Fetcher.all(%{}, Mix.Dep.Lock.read(), fetch_opts) diff --git a/lib/mix/lib/mix/tasks/deps.tree.ex b/lib/mix/lib/mix/tasks/deps.tree.ex index 6a59be32e65..3623b13ca5c 100644 --- a/lib/mix/lib/mix/tasks/deps.tree.ex +++ b/lib/mix/lib/mix/tasks/deps.tree.ex @@ -85,7 +85,7 @@ defmodule Mix.Tasks.Deps.Tree do deps_opts = for {switch, key} <- [only: :env, target: :target], value = opts[switch], - do: {key, :"#{value}"} + do: {key, String.to_unsafe_atom("#{value}")} deps = Mix.Dep.Converger.converge(deps_opts) diff --git a/lib/mix/lib/mix/tasks/deps.update.ex b/lib/mix/lib/mix/tasks/deps.update.ex index f9bed188fa9..6edabc3e2f6 100644 --- a/lib/mix/lib/mix/tasks/deps.update.ex +++ b/lib/mix/lib/mix/tasks/deps.update.ex @@ -58,7 +58,7 @@ defmodule Mix.Tasks.Deps.Update do fetch_opts = for {switch, key} <- [only: :env, target: :target], value = opts[switch], - do: {key, :"#{value}"} + do: {key, String.to_unsafe_atom("#{value}")} cond do opts[:all] -> diff --git a/lib/mix/test/mix/tasks/release_test.exs b/lib/mix/test/mix/tasks/release_test.exs index 4a79df298c7..aebcb44a548 100644 --- a/lib/mix/test/mix/tasks/release_test.exs +++ b/lib/mix/test/mix/tasks/release_test.exs @@ -10,7 +10,7 @@ defmodule Mix.Tasks.ReleaseTest do @erts_version :erlang.system_info(:version) @hostname :inet_db.gethostname() - defmacrop release_node(name), do: :"#{name}@#{@hostname}" + defmacrop release_node(name), do: String.to_unsafe_atom("#{name}@#{@hostname}") describe "customize" do test "env, vm.args and overlays templates" do