Skip to content

Commit 2a5eb30

Browse files
committed
More fixes
1 parent 8ee8575 commit 2a5eb30

3 files changed

Lines changed: 12 additions & 2 deletions

File tree

lib/elixir/lib/module/types.ex

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,10 @@ defmodule Module.Types do
7272

7373
stack = stack(:infer, file, module, {:__info__, 1}, env, cache, handler)
7474

75+
# In case there are loops, the other we traverse matters,
76+
# so we sort the definitions for determinism
7577
{types, private, %{local_sigs: reachable_sigs} = context} =
76-
for {fun_arity, kind, meta, _clauses} = def <- defs,
78+
for {fun_arity, kind, meta, _clauses} = def <- Enum.sort(defs),
7779
reduce: {[], [], context()} do
7880
{types, private, context} when kind in [:def, :defmacro] ->
7981
# Optimized version of finder, since we already have the definition

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1144,7 +1144,7 @@ defmodule Module.Types.Apply do
11441144
end
11451145

11461146
defp filter_domain([{args, return} | clauses], expected, acc, all_compatible?) do
1147-
case compatible?(return, expected) do
1147+
case compatible?(expected, return) do
11481148
true -> filter_domain(clauses, expected, [args | acc], all_compatible?)
11491149
false -> filter_domain(clauses, expected, acc, false)
11501150
end

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -419,6 +419,14 @@ defmodule Module.Types.PatternTest do
419419
"""
420420
end
421421

422+
test "is_binary/1" do
423+
assert typecheck!([x], is_binary(x), x) == dynamic(binary())
424+
assert typecheck!([x], not is_binary(x), x) == dynamic(term())
425+
426+
assert typecheck!([x], is_bitstring(x), x) == dynamic(binary())
427+
assert typecheck!([x], not is_bitstring(x), x) == dynamic(negation(binary()))
428+
end
429+
422430
test "is_function/2" do
423431
assert typecheck!([x], is_function(x, 3), x) == dynamic(fun(3))
424432
assert typecheck!([x], not is_function(x, 3), x) == dynamic(negation(fun(3)))

0 commit comments

Comments
 (0)