Skip to content

Commit 565f468

Browse files
Clean up unused in_body? code branch in in macro impl (#15112)
The dialyzer warning was: lib/kernel.ex:4836:7: Guard test _in_body?@1::'false' =:= 'true' can never succeed
1 parent c903033 commit 565f468

1 file changed

Lines changed: 6 additions & 14 deletions

File tree

lib/elixir/lib/kernel.ex

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4708,7 +4708,7 @@ defmodule Kernel do
47084708
# We only expand lists in the body if they are relatively
47094709
# short and it is made only of literal expressions.
47104710
case in_body? do
4711-
false -> in_list(left, head, tail, expand, list, in_body?)
4711+
false -> in_list(left, head, tail, expand, list)
47124712
true -> quote(do: :lists.member(unquote(left), unquote(right)))
47134713
end
47144714

@@ -4815,12 +4815,12 @@ defmodule Kernel do
48154815
end
48164816
end
48174817

4818-
defp in_list(left, head, tail, expand, right, in_body?) do
4819-
[head | tail] = :lists.map(&comp(left, &1, expand, right, in_body?), [head | tail])
4818+
defp in_list(left, head, tail, expand, right) do
4819+
[head | tail] = :lists.map(&comp(left, &1, expand, right), [head | tail])
48204820
:lists.foldl(&quote(do: Kernel.or(unquote(&2), unquote(&1))), head, tail)
48214821
end
48224822

4823-
defp comp(left, {:|, _, [head, tail]}, expand, right, in_body?) do
4823+
defp comp(left, {:|, _, [head, tail]}, expand, right) do
48244824
case expand.(tail) do
48254825
[] ->
48264826
quote(do: :erlang."=:="(unquote(left), unquote(head)))
@@ -4829,15 +4829,7 @@ defmodule Kernel do
48294829
quote do
48304830
Kernel.or(
48314831
:erlang."=:="(unquote(left), unquote(head)),
4832-
unquote(in_list(left, tail_head, tail, expand, right, in_body?))
4833-
)
4834-
end
4835-
4836-
tail when in_body? ->
4837-
quote do
4838-
Kernel.or(
4839-
:erlang."=:="(unquote(left), unquote(head)),
4840-
:lists.member(unquote(left), unquote(tail))
4832+
unquote(in_list(left, tail_head, tail, expand, right))
48414833
)
48424834
end
48434835

@@ -4846,7 +4838,7 @@ defmodule Kernel do
48464838
end
48474839
end
48484840

4849-
defp comp(left, right, _expand, _right, _in_body?) do
4841+
defp comp(left, right, _expand, _right) do
48504842
quote(do: :erlang."=:="(unquote(left), unquote(right)))
48514843
end
48524844

0 commit comments

Comments
 (0)