Fix bug in for comprehensions
This commit is contained in:
@@ -5,6 +5,7 @@
|
||||
|
||||
* Bug fixes
|
||||
* [ExUnit] Ensure doctest failures are properly reported
|
||||
* [Kernel] Fix a bug where comprehensions arguments were not properly take into account in the variable scope
|
||||
* [Mix] Fix issue on rebar install when the endpoint was redirecting to a relative uri
|
||||
|
||||
* Deprecations
|
||||
|
||||
@@ -282,6 +282,15 @@ foo
|
||||
assert_eval "\n\n Good\n \n", string
|
||||
end
|
||||
|
||||
test "for comprehensions" do
|
||||
string = """
|
||||
<%= for _name <- packages || [] do %>
|
||||
<% end %>
|
||||
<%= all || :done %>
|
||||
"""
|
||||
assert_eval "\ndone\n", string, packages: nil, all: nil
|
||||
end
|
||||
|
||||
test "unicode" do
|
||||
template = """
|
||||
• <%= "•" %> •
|
||||
@@ -367,8 +376,8 @@ foo
|
||||
assert {:wrapped, "foo"} = EEx.eval_string("foo", [], engine: TestEngine)
|
||||
end
|
||||
|
||||
defp assert_eval(expected, actual) do
|
||||
result = EEx.eval_string(actual, [], file: __ENV__.file, engine: EEx.Engine)
|
||||
defp assert_eval(expected, actual, binding \\ []) do
|
||||
result = EEx.eval_string(actual, binding, file: __ENV__.file, engine: EEx.Engine)
|
||||
assert result == expected
|
||||
end
|
||||
end
|
||||
|
||||
@@ -69,7 +69,7 @@ translate(Meta, Args, #elixir_scope{return=Return} = RS) ->
|
||||
|
||||
{TCases, SC} = translate_gen(Meta, Cases, [], SI),
|
||||
{TExpr, SE} = elixir_translator:translate_block(Expr, Return, SC),
|
||||
SF = elixir_scope:mergef(SI, SE),
|
||||
SF = elixir_scope:mergec(SI, SE),
|
||||
|
||||
case comprehension_expr(TInto, TExpr) of
|
||||
{inline, TIntoExpr} ->
|
||||
|
||||
Reference in New Issue
Block a user