Skip to content

Commit dff93a4

Browse files
author
José Valim
committed
Soft deprecate size/1
Closes #2356
1 parent f76c8fe commit dff93a4

File tree

3 files changed

+9
-13
lines changed

3 files changed

+9
-13
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
* [Kernel] Ensure Mix `_build` structure works on Windows when copying projects
1616

1717
* Soft deprecations (no warnings emitted)
18+
* [Kernel] `size/1` is deprecated, please use `byte_size/1` or `tuple_size/1` instead
1819
* [ExUnit] `teardown/2` and `teardown_all/2` are deprecated in favor of `on_exit/1` callbacks
1920

2021
* Deprecations

lib/elixir/lib/kernel.ex

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,11 @@ defmodule Kernel do
225225
:erlang.setelement(index + 1, tuple, value)
226226
end
227227

228+
@doc false
229+
def size(arg) do
230+
:erlang.size(arg)
231+
end
232+
228233
## END OF DEPRECATED
229234

230235
@doc """
@@ -665,18 +670,6 @@ defmodule Kernel do
665670
:erlang.self()
666671
end
667672

668-
@doc """
669-
Returns the size of the given argument, which must be a tuple or a binary.
670-
671-
Prefer using `tuple_size/1` or `byte_size/1` instead.
672-
673-
Allowed in guard tests. Inlined by the compiler.
674-
"""
675-
@spec size(tuple|binary) :: non_neg_integer
676-
def size(arg) do
677-
:erlang.size(arg)
678-
end
679-
680673
@doc """
681674
Spawns the given function and returns its pid.
682675

lib/elixir/src/elixir_dispatch.erl

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -444,7 +444,6 @@ inline(?kernel, 'rem', 2) -> {erlang, 'rem'};
444444
inline(?kernel, round, 1) -> {erlang, round};
445445
inline(?kernel, self, 0) -> {erlang, self};
446446
inline(?kernel, send, 2) -> {erlang, send};
447-
inline(?kernel, size, 1) -> {erlang, size};
448447
inline(?kernel, spawn, 1) -> {erlang, spawn};
449448
inline(?kernel, spawn, 3) -> {erlang, spawn};
450449
inline(?kernel, spawn_link, 1) -> {erlang, spawn_link};
@@ -483,6 +482,9 @@ inline(?string, to_integer, 2) -> {erlang, binary_to_integer};
483482
inline(?system, stacktrace, 0) -> {erlang, get_stacktrace};
484483
inline(?tuple, to_list, 1) -> {erlang, tuple_to_list};
485484

485+
%% DEPRECATED
486+
inline(?kernel, size, 1) -> {erlang, size};
487+
486488
inline(_, _, _) -> false.
487489

488490
check_deprecation(Meta, Receiver, Name, Arity, #{file := File}) ->

0 commit comments

Comments
 (0)