Skip to content

Commit 171da41

Browse files
committed
Infer only for single when clause
1 parent c7ce9ee commit 171da41

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -757,11 +757,13 @@ defmodule Module.Types.Pattern do
757757

758758
defp of_guards(guards, stack, context) do
759759
# TODO: This match? is temporary until we support multiple guards
760-
context = init_guard_info(context, match?([_], guards))
760+
single? = match?([_], guards)
761+
context = init_guard_info(context, single?)
762+
return = if single?, do: @atom_true, else: term()
761763

762764
context =
763765
Enum.reduce(guards, context, fn guard, context ->
764-
{type, context} = of_guard(guard, @atom_true, guard, stack, context)
766+
{type, context} = of_guard(guard, return, guard, stack, context)
765767

766768
if never_true?(type) do
767769
error = {:badguard, type, guard, context}

0 commit comments

Comments
 (0)