Skip to content

Commit f1a5e6a

Browse files
committed
Properly print warnings from tokenizer in EEx, closes #12926
1 parent fadf5c6 commit f1a5e6a

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

lib/eex/lib/eex/compiler.ex

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,8 @@ defmodule EEx.Compiler do
7272
{key, expr} =
7373
case :elixir_tokenizer.tokenize(expr, 1, file: "eex", check_terminators: false) do
7474
{:ok, _line, _column, warnings, tokens} ->
75-
Enum.each(Enum.reverse(warnings), fn {location, file, msg} ->
76-
:elixir_errors.erl_warn(location, file, msg)
75+
Enum.each(Enum.reverse(warnings), fn {location, msg} ->
76+
:elixir_errors.erl_warn(location, state.file, msg)
7777
end)
7878

7979
token_key(tokens, expr)

lib/eex/test/eex/tokenizer_test.exs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,13 @@ defmodule EEx.TokenizerTest do
55

66
@opts [indentation: 0, trim: false]
77

8-
test "simple chars lists" do
8+
test "tokenizer warning" do
9+
assert ExUnit.CaptureIO.capture_io(:stderr, fn ->
10+
EEx.tokenize(~c"foo <% :'bar' %>", @opts)
11+
end) =~ "found quoted atom \"bar\" but the quotes are not required"
12+
end
13+
14+
test "simple charlists" do
915
assert EEx.tokenize(~c"foo", @opts) ==
1016
{:ok, [{:text, ~c"foo", %{column: 1, line: 1}}, {:eof, %{column: 4, line: 1}}]}
1117
end

0 commit comments

Comments
 (0)