Ensure in_guards is properly set to true inside args.
This commit is contained in:
@@ -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
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user