Skip to content

Commit bef8caf

Browse files
author
José Valim
committed
Fix a bug on RecordRewriter when a variable is matched in many clauses, closes #1037
1 parent a514bfa commit bef8caf

File tree

2 files changed

+5
-0
lines changed

2 files changed

+5
-0
lines changed

lib/elixir/lib/kernel/record_rewriter.ex

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -363,6 +363,8 @@ defmodule Kernel.RecordRewriter do
363363
{ :ok, _ } -> :orddict.store(key, nil, acc)
364364
:error -> :orddict.erase(key, acc)
365365
end
366+
{ key, nil }, acc ->
367+
:orddict.store(key, nil, acc)
366368
end
367369

368370
join_dict(t, other)

lib/elixir/test/elixir/kernel/record_rewriter_test.exs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,9 @@ defmodule Kernel.RecordRewriterTest do
159159

160160
clause = clause(fn -> case something do 1 -> x = Macro.Env[]; 2 -> x = Range[] end end)
161161
assert optimize_clause(clause) == { clause, [x: nil], nil }
162+
163+
clause = clause(fn -> case something do x = Macro.Env[] -> x; x = Range[] -> x; _ -> :ok end end)
164+
assert optimize_clause(clause) == { clause, [x: nil], nil }
162165
end
163166

164167
test "inside case with nested tuple" do

0 commit comments

Comments
 (0)