decapo01

decapo01

Coming from the play framework and would like to give phoenix another try. A really nice thing about play is the typesafe template engine (Twirl). I’ve noticed phoenix will show me mistakes I’ve made when I’m loading the page that I’ve made a mistake on but I’d like for there to be a way if it would tell me when I’m not making a request to that page. Is that possible?

Showing Posts 1 to 3

OvermindDL1

OvermindDL1

For most languages on the beam typing is handled via the positive typing system included with the beam called Dialyzer. Elixir has a fantastic library that makes it so easy to use (it’s not otherwise terribly simple) called Dialyxir. :slight_smile:

And yes, it works on templates as well since templates get compiled to normal code. :slight_smile:

decapo01

decapo01 OP

I just gave it a shot and it did not catch my (contrived) template errors. Is there a configuration that I’m missing?

OvermindDL1

OvermindDL1

Hmm, sounds like a bug if so… Let me try a highly simplified test. Given this file:

defmodule EexDialyzeTest do
  @doc """

      iex> EexDialyzeTest.blah()
      Result: 42

  """
  def blah() do
    unquote(EEx.compile_string("Result: <%= 2+thingy() %>"))
  end

  def thingy() do
    :an_atom
  end
end

And the failing test:

  1) doctest EexDialyzeTest.blah/0 (1) (EexDialyzeTestTest)
     test/eex_dialyze_test_test.exs:3
     Doctest failed: got ArithmeticError with message "bad argument in arithmetic expression"
     code: EexDialyzeTest.blah()
     stacktrace:
       (eex_dialyze_test) lib/eex_dialyze_test.ex:1: EexDialyzeTest.blah/0
       (for doctest at) lib/eex_dialyze_test.ex:4: (test)

Then dialyzer ‘should’ catch that, let’s try…

╰─➤  mix dialyzer
Finding suitable PLTs
Checking PLT...
[:compiler, :crypto, :dialyxir, :dialyzer, :elixir, :hipe, :kernel, :logger, :mix, :stdlib, :wx]
PLT is up to date!
Starting Dialyzer
[
  check_plt: false,
  init_plt: '/home/overminddl1/tmp/eex_dialyze_test/_build/dev/dialyxir_erlang-21.0.1_elixir-1.7.0-rc.0_deps-dev.plt',
  files_rec: ['/home/overminddl1/tmp/eex_dialyze_test/_build/dev/lib/eex_dialyze_test/ebin'],
  warnings: [:unknown]
]
Total errors: 2, Skipped: 0
done in 0m2.58s
lib/eex_dialyze_test.ex:1:call
The call:
:erlang.+(2, :an_atom)

will never return since it differs in arguments with
positions 2 from the success typing arguments:

(number(), number())
________________________________________________________________________________
lib/eex_dialyze_test.ex:8:no_return
Function blah/0 has no local return.
________________________________________________________________________________
done (warnings were emitted)

It looks like it caught it just fine? Do you have a reproduceable test case?

— All posts loaded —

Where Next? Top

Trending in Questions Top

RSP87
I’m working on a project that simulates the bumbl example in the programming phoenix book. It acts almost like an email client. We have a...
New
nseaSeb
Hello, I know there is an approach for handling lists that allows for optimized traversal, but I can’t recall the specific method (somet...
New
kpanic
Hi everyone, I am toying with the idea of building a “match maker” for giving personal help to people that wants to start coding. I sta...
New
brecabral
Documentation While reading the Scoped Routes section, I noticed that the documentation currently refers to a problem without explainin...
New
velrest
So my question is quite simple and i have found no conclusive answer on forum, google or AI. Should we use :erlang.float for Integer to ...
New
asweet-confluent
I recently noticed that Elixir’s Logger defaults its primary log level to :debug when no :logger, :level application configuration is pre...
New
apz
I’m new to elixir and just tried to install the elixirLS extension for VScode(ium) and it is throwing some errors that I would like help ...
New

Other Trending Topics Top

GenericJam
Edit: 2026 May 15 - This post is archived. Mob is alive!! Main docs: mob v0.7.11 — Documentation A bit of explanation for the slightly c...
New
JesseHerrick
Hey, I’m Jesse and I’m the main contributor behind Dexter, a full-featured, lightning-fast Elixir LSP optimized for large codebases. It s...
New
mudasobwa
I am happy to introduce the very α version of the new programming language compiled to BEAM. Welcome Cure. It has literally three kille...
New
marciok
Hi there! We created Gust: A task orchestrator inspired by Airflow. For those who have never heard about Aiflow, it’s a Python-based wor...
New
mhanberg
Hi everyone! The first release candidate for the Expert language server project is now available! We’ve published a press release detai...
New
georgeguimaraes
Just published claude-code-elixir, a plugin marketplace for Claude Code with Elixir support. These are the plugins I’ve been using for my...
New

We're in Beta

About us Mission Statement

Options

Thread Display Mode




Thread Preview

Skip Thread Previews