jeremyjh

jeremyjh

Hi everyone,

Andrew Summers has been working on a feature for dialyxir that among other things will Elixirfy the Erlang term representations - in particular this will improve the readability of structs in dialyzer warnings. It also gives us the ability to tweak or expand on the wording of the messages.

Ideally we’d have a test suite based on a corpus of real-world warning messages - but that doesn’t really exist to my knowledge. This is at the point though that alpha testing would be helpful to identify cases where types are not parsed when they could be or fail when attempted.

If you’d like to help out, and your project is already using Elixir 1.6 (we rely on this to help with pretty printing) you can update your mix.exs to use this branch:

{:dialyxir, git: "https://github.com/jeremyjh/dialyxir", branch: "elixir-formatter", runtime: false}

If parsing fails with an exception dialyxir should automatically print the message using :dialyzer formatter (like it the released version does today). If that happens please post about it in the PR.

Also there is a new command line option --raw - if you see output that you think doesn’t look good or doesn’t parse things that want for parsing, please re-run with mix dialyzer --raw and post the output tuples to that PR.

Thanks in advance!

Showing Posts 1 to 10

jeremyjh

jeremyjh OP

This feature has merged to master - I really want to thank Andrew for all the work he’s put into this.

Also, I wanted to mention another feature Andrew added, which is --explain - this contains help text about what the class of warning means. So mix dialyzer --explain no_return will now do exactly that. Suggestions / improvements to this learning resource would be greatly appreciated.

14
Post #1
asummers

asummers

Thank you everyone for your bug reports and patience as I fixed them :smile: Please make issues with any unclear language or issues you might still be having! I think the output is substantially more readable, and encourage you to play around with it. The --format short option is particularly nice for CI pipelines.

axelson

axelson

Scenic Core Team

All of this sounds really interesting and useful and the output is already much more readable then the previous output. Quick question, is it possible to get the --explain output available via iEX?

asummers

asummers

Totally should be. Are you thinking in an editor capacity? Can you make an issue and we can work out the details.

asummers

asummers

Actually you can just invoke the explain/0 function in all the Dialyxir.Warnings modules.

iex(3)> Dialyxir.Warnings.BinaryConstruction.explain()

There currently isn’t an accessible list of all available warnings, but that should be trivial to throw behind a function.

Curious what the use case is though, we might be able to do better.

axelson

axelson

Scenic Core Team

That function doesn’t appear to be quite what I’m thinking. This is what I get:

iex(1)> Dialyxir.Warnings.BinaryConstruction.explain()
"This warning type does not have an explanation yet. If you have\ncode that causes it, please file an issue or pull request in\nhttps://github.com/jeremyjh/dialyxir/issues\n"

When I would want to be able to run something more like this:

iex(1)> Dialyxir.explain("no_return")
"The function has no return. This is usually due to an issue later
on in the call stack causing it to not be recognized as returning
for some reason. It is often helpful to cross reference the
complete list of warnings with the call stack in the function and
fix the deepest part of the call stack, which will usually fix
many of the other no_return errors.

defmodule Example do
  def ok() do
    Enum.each([1, 2, 3], fn _ -> raise \"error\" end)
  end
end

or

defmodule Example do
  def ok() do
    raise \"error\"

    :ok
  end

  def ok(:ok) do
    ok()
  end
end"

The use-case is either just accessing the explanations via iEX manually while coding, as well as I can forsee it being useful for an editor integration.

asummers

asummers

Right, so that one is just missing an explanation. if you call:

iex(7)> IO.puts Dialyxir.Warnings.NoReturn.explain()
The function has no return. This is usually due to an issue later
on in the call stack causing it to not be recognized as returning
for some reason. It is often helpful to cross reference the
complete list of warnings with the call stack in the function and
fix the deepest part of the call stack, which will usually fix
many of the other no_return errors.

defmodule Example do
  def ok() do
    Enum.each([1, 2, 3], fn _ -> raise "error" end)
  end
end

or

defmodule Example do
  def ok() do
    raise "error"

    :ok
  end

  def ok(:ok) do
    ok()
  end
end

:ok:

I think it will do what you want. I’m not sure how to force it to respect the new lines besides IO.puts.

axelson

axelson

Scenic Core Team

But from an output like:

apps/web_interface/lib/web_interface/controllers/api/page_controller.ex:47:no_return
Function join/2 has no local return.

How is a user supposed know that maps no_return maps to Dialyxir.Warnings.NoReturn?

asummers

asummers

Totally fair question, that part is missing :slight_smile:

asummers

asummers

@axelson Added Dialyxir.Warnings.warnings/0 that will give the atom to module mapping, so you can to_string or whatever else you need to do from there. Also adds a --list option to just see them in general. Please open a GitHub issue if that isn’t sufficient :smile: :heart:

https://github.com/jeremyjh/dialyxir/pull/171/files

Where Next? Top

Trending in Announcing Top

woylie
Flop is an Elixir library that applies filtering, ordering and pagination parameters to your Ecto queries. offset-based pagination with...
New
MRdotB
I needed to reuse React components from my Chrome extension in my Phoenix/LiveView backend. I noticed that for Svelte/Vue, there are live...
New
woylie
I released Doggo, a collection of unstyled Phoenix components. https://github.com/woylie/doggo Features Unstyled Phoenix components....
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
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
anuaralfetahe
Hello Published a new library - ProcessHub! ProcessHub is a library designed to manage process distribution within the Elixir cluster. ...
New
jimsynz
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New

Other Trending Topics Top

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
mhanberg
Hi everyone! The first release candidate for the Expert language server project is now available! We’ve published a press release detai...
New
webofbits
With AI doing more of the implementation work, I’ve been wondering how much coding I should deliberately keep doing myself. My main conc...
#ai
New
sergio
It’s not that it’s vocabulary is too advanced. It’s something worse. I get lost trying to follow even a paragraph written by Claude. It’...
New
AstonJ
This showed up on my feed.. anyone heard of it? Just hype? Ox Alpha is a reasoning model designed for coding, sustained ag...
New
bartblast
Hey folks, I just published a post about Hologram’s funding and where the project goes next - the short version: Curiosum as Main Spons...
New

Latest on Elixir Forum

Elixir Forum

We're in Beta

About us Mission Statement

Options

Thread Display Mode




Thread Preview

Skip Thread Previews