Ensure in_guards is properly set to true inside args.

This commit is contained in:
José Valim
2012-03-30 10:02:48 +02:00
parent 9675cdced6
commit 11d6ea577f
2 changed files with 6 additions and 5 deletions
+2 -1
View File
@@ -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
+4 -4
View File
@@ -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