Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/elixir/src/elixir_erl_pass.erl
Original file line number Diff line number Diff line change
Expand Up @@ -426,7 +426,7 @@ translate_with_else(Meta, [{'else', Else}], S) ->

Clauses = elixir_erl_clauses:get_clauses('else', [{'else', Else ++ [RaiseClause]}], match),
{TranslatedClauses, SC} = elixir_erl_clauses:clauses(Clauses, SV#elixir_erl{extra=pin_guard}),
with_else_closure(Meta, TranslatedClauses, SC#elixir_erl{extra=SV#elixir_erl.extra}).
with_else_closure(Generated, TranslatedClauses, SC#elixir_erl{extra=SV#elixir_erl.extra}).

with_else_closure(Meta, TranslatedClauses, S) ->
Ann = ?ann(Meta),
Expand Down
12 changes: 12 additions & 0 deletions lib/elixir/test/elixir/fixtures/dialyzer/with_throwing_else.ex
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
defmodule Dialyzer.WithThrowingElse do
def with_throwing_else(map) do
with {:ok, foo} <- Map.fetch(map, :foo),
false <- Enum.empty?(foo) do
foo
else
# several clauses but one is a no_return
:error -> throw(:empty_map)
true -> nil
end
end
end
6 changes: 6 additions & 0 deletions lib/elixir/test/elixir/kernel/dialyzer_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ defmodule Kernel.DialyzerTest do
:elixir,
:elixir_env,
:elixir_erl_pass,
:maps,
ArgumentError,
Atom,
Code,
Expand Down Expand Up @@ -164,6 +165,11 @@ defmodule Kernel.DialyzerTest do
assert_dialyze_no_warnings!(context)
end

test "no warnings on with when multiple else clauses and one is a no_return", context do
copy_beam!(context, Dialyzer.WithThrowingElse)
assert_dialyze_no_warnings!(context)
end

test "no warnings on defmacrop", context do
copy_beam!(context, Dialyzer.Defmacrop)
assert_dialyze_no_warnings!(context)
Expand Down
Loading