Skip to content

Commit eedc9bc

Browse files
author
José Valim
committed
Do not build matches if variables are the same
Signed-off-by: José Valim <[email protected]>
1 parent f053df8 commit eedc9bc

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

lib/elixir/src/elixir_clauses.erl

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -198,17 +198,17 @@ normalize_vars(Key, {Ref, Counter, _Safe},
198198
% Generate match vars by checking if they were updated
199199
% or not and assigning the previous value.
200200

201-
generate_match_vars([{Key, Value, Expr} | T], ClauseVars, Left, Right) ->
201+
generate_match_vars([{Key, {Value, _, _}, Expr} | T], ClauseVars, Left, Right) ->
202202
case maps:find(Key, ClauseVars) of
203-
{ok, Value} ->
203+
{ok, {Value, _, _}} ->
204204
generate_match_vars(T, ClauseVars, Left, Right);
205-
{ok, Clause} ->
205+
{ok, {Clause, _, _}} ->
206206
generate_match_vars(T, ClauseVars,
207-
[{var, 0, element(1, Value)} | Left],
208-
[{var, 0, element(1, Clause)} | Right]);
207+
[{var, 0, Value} | Left],
208+
[{var, 0, Clause} | Right]);
209209
error ->
210210
generate_match_vars(T, ClauseVars,
211-
[{var, 0, element(1, Value)} | Left], [Expr | Right])
211+
[{var, 0, Value} | Left], [Expr | Right])
212212
end;
213213

214214
generate_match_vars([], _ClauseVars, Left, Right) ->

0 commit comments

Comments
 (0)