Skip to content

Commit 3a7af7a

Browse files
committed
Add :erlang.--/2 parametric TODO and cover static non-empty subtraction
1 parent 9ef2808 commit 3a7af7a

2 files changed

Lines changed: 3 additions & 0 deletions

File tree

lib/elixir/lib/module/types/apply.ex

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1153,6 +1153,8 @@ defmodule Module.Types.Apply do
11531153
end
11541154

11551155
defp remote_apply(:erlang, :--, _info, [left, right], stack) do
1156+
# TODO: remove once we add parametric types, this will just be:
1157+
# list(a), list(term()) -> list(a)
11561158
case {list_of(left), list_of(right)} do
11571159
{{_, list_of}, {_, _}} ->
11581160
result = if list_of, do: list(list_of), else: empty_list()

lib/elixir/test/elixir/module/types/expr_test.exs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,7 @@ defmodule Module.Types.ExprTest do
176176

177177
test "--" do
178178
assert typecheck!([x], [1, 2, 3] -- x) == list(integer())
179+
assert typecheck!([1] -- [1]) == list(integer())
179180
assert typecheck!([x], [] -- x) == empty_list()
180181

181182
assert typeerror!([x], [1, 2, 3] -- String.to_integer(x)) |> strip_ansi() =~

0 commit comments

Comments
 (0)