Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add some specs to IEx.Helpers #13372

Merged
merged 1 commit into from
Feb 27, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions lib/iex/lib/iex/helpers.ex
Original file line number Diff line number Diff line change
Expand Up @@ -1346,6 +1346,7 @@ defmodule IEx.Helpers do
#PID<0.0.0>

"""
@spec pid(binary | atom) :: pid()
def pid("#PID<" <> string) do
:erlang.list_to_pid(~c"<#{string}")
end
Expand Down Expand Up @@ -1373,6 +1374,7 @@ defmodule IEx.Helpers do
#PID<0.64.2048>

"""
@spec pid(non_neg_integer, non_neg_integer, non_neg_integer) :: pid()
def pid(x, y, z)
when is_integer(x) and x >= 0 and is_integer(y) and y >= 0 and is_integer(z) and z >= 0 do
:erlang.list_to_pid(
Expand All @@ -1392,6 +1394,7 @@ defmodule IEx.Helpers do

"""
@doc since: "1.8.0"
@spec port(binary) :: port()
def port(string) when is_binary(string) do
:erlang.list_to_port(~c"#Port<#{string}>")
end
Expand All @@ -1408,6 +1411,7 @@ defmodule IEx.Helpers do

"""
@doc since: "1.8.0"
@spec port(non_neg_integer, non_neg_integer) :: port()
def port(major, minor)
when is_integer(major) and major >= 0 and is_integer(minor) and minor >= 0 do
:erlang.list_to_port(
Expand All @@ -1425,6 +1429,7 @@ defmodule IEx.Helpers do

"""
@doc since: "1.6.0"
@spec ref(binary) :: reference()
def ref(string) when is_binary(string) do
:erlang.list_to_ref(~c"#Ref<#{string}>")
end
Expand All @@ -1439,6 +1444,7 @@ defmodule IEx.Helpers do

"""
@doc since: "1.6.0"
@spec ref(non_neg_integer, non_neg_integer, non_neg_integer, non_neg_integer) :: reference()
def ref(w, x, y, z)
when is_integer(w) and w >= 0 and is_integer(x) and x >= 0 and is_integer(y) and y >= 0 and
is_integer(z) and z >= 0 do
Expand Down