EEx functions not recognized by dialyzer

Background

I am trying to use diallyzer in a project, however it is throwing errors that I don’t believe are accurate.

Code

@spec new(keyword) :: __MODULE__.t
def new(fields) do
  raw = Keyword.fetch!(fields, :raw)
  struct!(__MODULE__, Keyword.put(fields, :compiled, EEx.compile_string(raw)))
end

Error

:0:unknown_function
Function EEx.compile_string/1 does not exist.

Question

I don’t understand where this is coming from, since the function does exist.

How can I fix this?

Have you put :eex to the list of :extra_applications?

5 Likes

I knew I was missing something. Thanks for clearing it out !

I think we can also pass it to dialyzer.

def project do
  [
    dialyzer: [
      plt_add_apps: [:eex]
    ]
  ]
end
2 Likes