Skip to content

Commit 9cbab98

Browse files
committed
Defaults to true
1 parent f0c3269 commit 9cbab98

2 files changed

Lines changed: 4 additions & 4 deletions

File tree

lib/elixir/lib/module/types/pattern.ex

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -771,7 +771,7 @@ defmodule Module.Types.Pattern do
771771

772772
context =
773773
Enum.reduce(guards, context, fn guard, context ->
774-
{type, context} = of_guard(guard, {true, term()}, guard, stack, context)
774+
{type, context} = of_guard(guard, {true, @atom_true}, guard, stack, context)
775775

776776
if never_true?(type) do
777777
error = {:badguard, type, guard, context}
@@ -899,7 +899,7 @@ defmodule Module.Types.Pattern do
899899
end
900900
end
901901

902-
# TODO: Move orelse and andalso handling here
902+
# TODO: Move orelse and andalso handling here, both may never be executed
903903
defp of_remote(fun, meta, [left, right], call, {_root, expected}, stack, context)
904904
when fun in [:or, :orelse] do
905905
{info, [left_domain, right_domain], context} =

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -431,7 +431,7 @@ defmodule Module.Types.PatternTest do
431431

432432
test "elem" do
433433
assert typecheck!([x], elem(x, 1), x) ==
434-
dynamic(open_tuple([term(), term()]))
434+
dynamic(open_tuple([term(), atom([true])]))
435435

436436
assert typecheck!([x], not elem(x, 1), x) ==
437437
dynamic(open_tuple([term(), atom([false])]))
@@ -442,7 +442,7 @@ defmodule Module.Types.PatternTest do
442442

443443
test "map.field" do
444444
assert typecheck!([x = %{foo: :bar}], x.bar, x) ==
445-
dynamic(open_map(foo: atom([:bar]), bar: term()))
445+
dynamic(open_map(foo: atom([:bar]), bar: atom([true])))
446446

447447
assert typecheck!([x = %{foo: :bar}], not x.bar, x) ==
448448
dynamic(open_map(foo: atom([:bar]), bar: atom([false])))

0 commit comments

Comments
 (0)