Skip to content

Commit 53fb96c

Browse files
authored
Fix EEx.compile_string passing invalid options to tokenize (elixir-lang#14835)
EEx.compile_string/2 was passing all options to tokenize/2, but tokenize/2 only accepts tokenize_opt (:file, :line, :column, :indentation, :trim). This caused dialyzer to correctly flag calls with :engine or :parser_options as type errors in Elixir 1.19+. The fix filters options before passing to tokenize/2, keeping only the valid tokenize_opt keys, while still passing the full options list to EEx.Compiler.compile/3 which needs :engine, :parser_options, and custom engine options. Fixes elixir-lang#14834
1 parent 504c680 commit 53fb96c

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

lib/eex/lib/eex.ex

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,9 @@ defmodule EEx do
236236
"""
237237
@spec compile_string(String.t(), [compile_opt]) :: Macro.t()
238238
def compile_string(source, options \\ []) when is_binary(source) and is_list(options) do
239-
case tokenize(source, options) do
239+
tokenize_opts = Keyword.take(options, [:file, :line, :column, :indentation, :trim])
240+
241+
case tokenize(source, tokenize_opts) do
240242
{:ok, tokens} ->
241243
EEx.Compiler.compile(tokens, source, options)
242244

0 commit comments

Comments
 (0)