diff --git a/lib/elixir/special_forms.ex b/lib/elixir/special_forms.ex index f74f8cc5ba..6fcc15b714 100644 --- a/lib/elixir/special_forms.ex +++ b/lib/elixir/special_forms.ex @@ -374,7 +374,8 @@ defmodule Elixir.SpecialForms do unexpected, for this reason, we save the result in a variable. In the example above, `in_guard` is allowing us to customize - the same macro to work inside and outside guards. + the same macro to work inside and outside guards. Notice that + `in_guard` is true when inside the arguments clause. """ defmacro in_guard(do: do_block, else: else_block) end \ No newline at end of file diff --git a/src/elixir_clauses.erl b/src/elixir_clauses.erl index 92fc4bc72c..0562960a81 100644 --- a/src/elixir_clauses.erl +++ b/src/elixir_clauses.erl @@ -22,12 +22,12 @@ assigns_block(Line, Fun, BareArgs, Exprs, S) -> assigns_block(Line, Fun, Args, Exprs, extract_guard_clauses(Guards), S). assigns_block(Line, Fun, Args, Exprs, Guards, S) -> - { TArgs, SA } = elixir_clauses:assigns(Fun, Args, S), - { TExprs, SE } = elixir_translator:translate(Exprs, SA), + { TArgs, SA } = elixir_clauses:assigns(Fun, Args, S#elixir_scope{guard=true}), FArgs = listify(TArgs), - SG = SA#elixir_scope{guard=true}, - FGuards = [translate_guard(Line, Guard, SG) || Guard <- Guards], + FGuards = [translate_guard(Line, Guard, SA) || Guard <- Guards], + + { TExprs, SE } = elixir_translator:translate(Exprs, SA#elixir_scope{guard=false}), % Uncompact expressions from the block. case TExprs of