Skip to content

Commit 098c01a

Browse files
committed
Introduce deprecations scheduled for v1.19
1 parent e3bbef3 commit 098c01a

File tree

34 files changed

+339
-148
lines changed

34 files changed

+339
-148
lines changed

CHANGELOG.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,23 @@
1414

1515
### 4. Hard deprecations
1616

17+
#### Elixir
18+
19+
* [Code] The `on_undefined_variable: :warn` is deprecated. Relying on undefined variables becoming function calls will not be supported in the future
20+
* [File] Passing a callback as third argument to `File.cp/3` is deprecated, pass it as a `on_conflict: callback` option instead
21+
* [File] Passing a callback as third argument to `File.cp_r/3` is deprecated, pass it as a `on_conflict: callback` option instead
22+
* [Kernel] Using `size(var)` in bitstrings requires the pin operator on the variable if the variable was defined outside of the current pattern
23+
* [Kernel.ParallelCompiler] Passing `return_diagnostics: true` as an option is required on `compile`, `compile_to_path` and `require`
24+
25+
#### Logger
26+
27+
* [Logger] The `:backends` configuration is deprecated, either set the `:default_handler` to false or start backends in your application start callback
28+
29+
#### Mix
30+
31+
* [mix] The `:default_task`, `:preferred_cli_env`, and `:preferred_cli_target` configuration inside `def project` in your `mix.exs` has been deprecated in favor of `:default_task`, `:preferred_envs` and `:preferred_targets` inside the `def cli` function
32+
* [mix do] Using commas as task separator in `mix do` (such as `mix do foo, bar`) is deprecated, use `+` instead (as in `mix do foo + bar`)
33+
1734
## v1.18
1835

1936
The CHANGELOG for v1.18 releases can be found [in the v1.18 branch](https://github.com/elixir-lang/elixir/blob/v1.18/CHANGELOG.md).

lib/elixir/lib/code.ex

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1747,6 +1747,17 @@ defmodule Code do
17471747
# TODO: Remove this option on Elixir v2.0
17481748
# TODO: Warn if mode is :warn on Elixir v1.19
17491749
def put_compiler_option(:on_undefined_variable, value) when value in [:raise, :warn] do
1750+
if value == :warn do
1751+
IO.warn_once(
1752+
{__MODULE__, :on_undefined_variable},
1753+
fn ->
1754+
"setting :on_undefined_variable to :warn is deprecated. " <>
1755+
"The warning behaviour will be removed in future releases"
1756+
end,
1757+
3
1758+
)
1759+
end
1760+
17501761
:elixir_config.put(:on_undefined_variable, value)
17511762
:ok
17521763
end

lib/elixir/lib/config.ex

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,15 +131,14 @@ defmodule Config do
131131
132132
config :logger,
133133
level: :warn,
134-
backends: [:console]
135134
136135
config :logger,
137136
level: :info,
138137
truncate: 1024
139138
140139
will have a final configuration for `:logger` of:
141140
142-
[level: :info, backends: [:console], truncate: 1024]
141+
[level: :info, truncate: 1024]
143142
144143
"""
145144
@doc since: "1.9.0"

lib/elixir/lib/enum.ex

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2430,7 +2430,7 @@ defmodule Enum do
24302430
{:ok, count, fun} when is_function(fun, 3) ->
24312431
fun.(random_count(count), 1, 1)
24322432

2433-
# TODO: Remove deprecation on Elixir v1.20.
2433+
# TODO: Remove me on v2.0
24342434
{:ok, count, fun} when is_function(fun, 2) ->
24352435
IO.warn(
24362436
"#{inspect(Enumerable.impl_for(enumerable))} must return a three arity function on slice/1"
@@ -4584,7 +4584,7 @@ defmodule Enum do
45844584
amount = Kernel.min(amount, count - start) |> amount_with_step(step)
45854585
fun.(start, amount, step)
45864586

4587-
# TODO: Remove me on v2.0.
4587+
# TODO: Remove me on v2.0
45884588
{:ok, count, fun} when is_function(fun, 2) ->
45894589
IO.warn(
45904590
"#{inspect(Enumerable.impl_for(enumerable))} must return a three arity function on slice/1"

lib/elixir/lib/file.ex

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -831,6 +831,14 @@ defmodule File do
831831

832832
# TODO: Deprecate me on Elixir v1.19
833833
def cp(source_file, destination_file, callback) when is_function(callback, 2) do
834+
IO.warn_once(
835+
{__MODULE__, :cp},
836+
fn ->
837+
"passing a callback to File.cp/3 is deprecated, pass it as a on_conflict: callback option instead"
838+
end,
839+
3
840+
)
841+
834842
cp(source_file, destination_file, on_conflict: callback)
835843
end
836844

@@ -936,6 +944,14 @@ defmodule File do
936944

937945
# TODO: Deprecate me on Elixir v1.19
938946
def cp_r(source, destination, callback) when is_function(callback, 2) do
947+
IO.warn_once(
948+
{__MODULE__, :cp_r},
949+
fn ->
950+
"passing a callback to File.cp_r/3 is deprecated, pass it as a on_conflict: callback option instead"
951+
end,
952+
3
953+
)
954+
939955
cp_r(source, destination, on_conflict: callback)
940956
end
941957

lib/elixir/lib/kernel/cli.ex

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -467,7 +467,7 @@ defmodule Kernel.CLI do
467467

468468
if files != [] do
469469
wrapper(fn ->
470-
case Kernel.ParallelCompiler.require(files) do
470+
case Kernel.ParallelCompiler.require(files, return_diagnostics: true) do
471471
{:ok, _, _} -> :ok
472472
{:error, _, _} -> exit({:shutdown, 1})
473473
end
@@ -503,7 +503,11 @@ defmodule Kernel.CLI do
503503

504504
opts =
505505
verbose_opts ++
506-
[profile: config.profile, warnings_as_errors: config.warnings_as_errors]
506+
[
507+
profile: config.profile,
508+
warnings_as_errors: config.warnings_as_errors,
509+
return_diagnostics: true
510+
]
507511

508512
case Kernel.ParallelCompiler.compile_to_path(files, output, opts) do
509513
{:ok, _, _} -> :ok

lib/elixir/lib/kernel/parallel_compiler.ex

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ defmodule Kernel.ParallelCompiler do
222222
end
223223

224224
@doc false
225-
# TODO: Deprecate me on Elixir v1.19
225+
@deprecated "Use Code.print_diagnostic/2 instead"
226226
def print_warning({file, location, warning}) do
227227
:elixir_errors.print_warning(location, file, warning)
228228
end
@@ -284,10 +284,10 @@ defmodule Kernel.ParallelCompiler do
284284
Module.ParallelChecker.stop(cache)
285285
end
286286

287-
# TODO: Require this to be set from Elixir v1.19
288287
if Keyword.get(options, :return_diagnostics, false) do
289288
{status, modules_or_errors, info}
290289
else
290+
IO.warn("you must pass return_diagnostics: true when invoking Kernel.ParallelCompiler")
291291
to_tuples = &Enum.map(&1, fn diag -> {diag.file, diag.position, diag.message} end)
292292

293293
modules_or_errors =

lib/elixir/pages/references/compatibility-and-deprecations.md

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,18 @@ The first column is the version the feature was hard deprecated. The second colu
8484

8585
Version | Deprecated feature | Replaced by (available since)
8686
:-------| :-------------------------------------------------- | :---------------------------------------------------------------
87+
[v1.19] | CLI configuration in `def project` inside `mix.exs` | Moving it to `def cli` (v1.14)
88+
[v1.19] | Using `,` to separate tasks in `mix do` | Using `+` (v1.14)
89+
[v1.19] | Logger's `:backends` configuration | Logger's `:default_handler` configuration (v1.15)
90+
[v1.19] | Passing a callback to `File.cp`/`File.cp_r` | The `:on_conflict` option (v1.14)
91+
[v1.18] | `<%#` in EEx | `<%!--` (v1.14) or `<% #` (v1.0)
92+
[v1.18] | `handle_text/2` callback in EEx | `handle_text/3` (v1.14)
93+
[v1.18] | Returning 2-arity fun from `Enumerable.slice/1` | Returning 3-arity (v1.14)
94+
[v1.18] | Ranges with negative steps in `Range.new/2` | Explicit steps in ranges (v1.11)
95+
[v1.18] | `Tuple.append/2` | `Tuple.insert_at/3` (v1.0)
96+
[v1.18] | `mix cmd --app APP` | `mix do --app APP` (v1.14)
97+
[v1.18] | `List.zip/1` | `Enum.zip/1` (v1.0)
98+
[v1.18] | `Module.eval_quoted/3` | `Code.eval_quoted/3` (v1.0)
8799
[v1.17] | Single-quoted charlists (`'foo'`) | `~c"foo"` (v1.0)
88100
[v1.17] | `left..right` in patterns and guards | `left..right//step` (v1.11)
89101
[v1.17] | `ExUnit.Case.register_test/4` | `register_test/6` (v1.10)
@@ -216,4 +228,23 @@ Version | Deprecated feature | Replaced by (ava
216228
[v1.14]: https://github.com/elixir-lang/elixir/blob/v1.14/CHANGELOG.md#4-hard-deprecations
217229
[v1.15]: https://github.com/elixir-lang/elixir/blob/v1.15/CHANGELOG.md#4-hard-deprecations
218230
[v1.16]: https://github.com/elixir-lang/elixir/blob/v1.16/CHANGELOG.md#4-hard-deprecations
219-
[v1.17]: https://github.com/elixir-lang/elixir/blob/main/CHANGELOG.md#4-hard-deprecations
231+
[v1.17]: https://github.com/elixir-lang/elixir/blob/v1.17/CHANGELOG.md#4-hard-deprecations
232+
[v1.18]: https://github.com/elixir-lang/elixir/blob/v1.18/CHANGELOG.md#4-hard-deprecations
233+
[v1.19]: https://github.com/elixir-lang/elixir/blob/main/CHANGELOG.md#4-hard-deprecations
234+
235+
#### Elixir
236+
237+
* [Code] The `on_undefined_variable: :warn` is deprecated. Relying on undefined variables becoming function calls will not be supported in the future
238+
239+
* [Kernel] Using `size(var)` in bitstrings requires the pin operator on the variable if the variable was defined outside of the current pattern
240+
* [Kernel.ParallelCompiler] Passing `return_diagnostics: true` as an option is required on `compile`, `compile_to_path` and `require`
241+
242+
#### Logger
243+
244+
* [Logger] `Logger.enable/1` is deprecated in favor of `Logger.delete_process_level/1`
245+
* [Logger] The `:backends` configuration is deprecated, either set the `:default_handler` to false or start backends in your application start callback
246+
247+
#### Mix
248+
249+
* [mix] The `:default_task`, `:preferred_cli_env`, and `:preferred_cli_target` configuration inside `def project` in your `mix.exs` has been deprecated in favor of `:default_task`, `:preferred_envs` and `:preferred_targets` inside the `def cli` function
250+
* [mix do] Using commas as task separator in `mix do` (such as `mix do foo, bar`) is deprecated, use `+` instead (as in `mix do foo + bar`)

lib/elixir/src/elixir_expand.erl

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -417,9 +417,8 @@ expand({Name, Meta, Kind}, S, E) when is_atom(Name), is_atom(Kind) ->
417417
{ok, CurrentVersion};
418418

419419
is_map_key(Pair, Pre) ->
420-
%% TODO: Enable this warning on Elixir v1.19
421420
%% TODO: Remove me on Elixir 2.0
422-
%% elixir_errors:file_warn(Meta, E, ?MODULE, {unpinned_bitsize_var, Name, Kind}),
421+
elixir_errors:file_warn(Meta, E, ?MODULE, {unpinned_bitsize_var, Name, Kind}),
423422
{ok, CurrentVersion};
424423

425424
not is_map_key(Pair, Original) ->

lib/elixir/test/elixir/file_test.exs

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -431,11 +431,13 @@ defmodule FileTest do
431431
try do
432432
assert File.exists?(dest)
433433

434-
assert File.cp(src, dest, fn src_file, dest_file ->
435-
assert src_file == src
436-
assert dest_file == dest
437-
false
438-
end) == :ok
434+
assert File.cp(src, dest,
435+
on_conflict: fn src_file, dest_file ->
436+
assert src_file == src
437+
assert dest_file == dest
438+
false
439+
end
440+
) == :ok
439441

440442
assert File.read!(dest) == "hello"
441443
after
@@ -734,11 +736,13 @@ defmodule FileTest do
734736
try do
735737
assert File.exists?(tmp_path("tmp/a/1.txt"))
736738

737-
File.cp_r(src, dest, fn src_file, dest_file ->
738-
assert src_file == fixture_path("cp_r/a/1.txt")
739-
assert dest_file == tmp_path("tmp/a/1.txt")
740-
false
741-
end)
739+
File.cp_r(src, dest,
740+
on_conflict: fn src_file, dest_file ->
741+
assert src_file == fixture_path("cp_r/a/1.txt")
742+
assert dest_file == tmp_path("tmp/a/1.txt")
743+
false
744+
end
745+
)
742746

743747
assert File.read!(tmp_path("tmp/a/1.txt")) == "hello"
744748
after
@@ -790,7 +794,7 @@ defmodule FileTest do
790794
assert src_mode == dest_mode
791795

792796
# On overwrite
793-
File.cp!(src, dest, fn _, _ -> true end)
797+
File.cp!(src, dest, on_conflict: fn _, _ -> true end)
794798
%File.Stat{mode: src_mode} = File.stat!(src)
795799
%File.Stat{mode: dest_mode} = File.stat!(dest)
796800
assert src_mode == dest_mode

0 commit comments

Comments
 (0)