Skip to content

Commit 2fee17e

Browse files
author
José Valim
committed
Deprecate Kernel.float/1 in favor of explicit conversion
1 parent ebb5500 commit 2fee17e

File tree

4 files changed

+4
-2
lines changed

4 files changed

+4
-2
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
* [File] `File.iterator/1` and `File.biniterator/1` are deprecated in favor of `IO.stream/1` and `IO.binstream/1`
2828
* [File] `File.iterator!/2` and `File.biniterator!/2` are deprecated in favor of `File.stream!/2` and `File.binstream!/2`
2929
* [Kernel] Deprecate recently added `quote binding: ...` in favor of the clearer `quote bind_quoted: ...`
30+
* [Kernel] Deprecate `Kernel.float/1` in favor of a explicit conversion
3031
* [Record] `Record.__index__/2` deprecated in favor of `Record.__record__(:index, key)`
3132

3233
* backwards incompatible changes

lib/elixir/lib/kernel.ex

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -607,6 +607,7 @@ defmodule Kernel do
607607
"""
608608
@spec float(number) :: float
609609
def float(number) do
610+
IO.write "[WARNING] Kernel.float is deprecated, please do an explicit conversion instead\n#{Exception.format_stacktrace}"
610611
:erlang.float(number)
611612
end
612613

lib/elixir/lib/string.ex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -854,7 +854,7 @@ defmodule String do
854854
{int_result, int_remainder} = :string.to_integer(charlist)
855855
case int_result do
856856
:error -> :error
857-
_ -> {float(int_result), list_to_binary(int_remainder)}
857+
_ -> {:erlang.float(int_result), list_to_binary(int_remainder)}
858858
end
859859
_ -> {result, list_to_binary(remainder)}
860860
end

lib/elixir/src/elixir_dispatch.erl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -381,7 +381,7 @@ in_erlang_functions() ->
381381
{ byte_size, 1 },
382382
% { date, 0 },
383383
{ exit, 1 },
384-
{ float, 1 },
384+
% { float, 1 },
385385
{ float_to_binary, 1 },
386386
{ float_to_list, 1 },
387387
{ hd, 1 },

0 commit comments

Comments
 (0)