diff --git a/CHANGELOG.md b/CHANGELOG.md index 95673b2ae3..e8755816c4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/lib/eex/test/eex_test.exs b/lib/eex/test/eex_test.exs index 2ecea256a4..b50f27cec9 100644 --- a/lib/eex/test/eex_test.exs +++ b/lib/eex/test/eex_test.exs @@ -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 diff --git a/lib/elixir/src/elixir_for.erl b/lib/elixir/src/elixir_for.erl index 312ab9ad35..c539abe7cc 100644 --- a/lib/elixir/src/elixir_for.erl +++ b/lib/elixir/src/elixir_for.erl @@ -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} ->