sax

sax

Confusing dialyzer warning

Every time I run into an issue with dialyzer, it’s my fault. I respect that, and predict that it’s also the case here. I’m stumped with this one, though.

I’m using a with statement that may return two different matches. I use this same with statement twice. In one of the statements, dialyzer only sees the return values from one of the function calls.

If anyone has some spare moments to take a look at the code, I’d appreciate any pointers.

lib/dyd.ex:101:pattern_match
The pattern can never match the type.

Pattern:
{:error, {:invalid_toml, _error}}

Type:
{:error, :invalid_time_unit | :not_a_datetime}

Here is the offending line, pinned to a specific commit:
https://github.com/geometerio/dyd/blob/fee50b18962f0f63dfbe411b242c8c5a87f47dd7/lib/dyd.ex#L101

Here is the second usage, which does not generate any warnings:
https://github.com/geometerio/dyd/blob/fee50b18962f0f63dfbe411b242c8c5a87f47dd7/lib/dyd.ex#L136

Here is the spec that should make the statement valid:
https://github.com/geometerio/dyd/blob/fee50b18962f0f63dfbe411b242c8c5a87f47dd7/lib/dyd/manifest.ex#L41

This is with the following versions:

  • OTP: 24.2.1
  • Elixir: 1.13.3
  • Dialyxir: 1.1.0

Marked As Solved

al2o3cr

al2o3cr

This may not be the same underlying issue, but the situation (else clauses with no_return in each fail type analysis) sounds really similar:

https://github.com/elixir-lang/elixir/issues/10385

or this (also linked to the same open issue):

https://github.com/elixir-lang/elixir/issues/7177

Last Post!

sax

sax

Cool, thanks for the links! That gives me some ideas for how I could rewrite this to avoid the condition. Fortunately it’s a CLI app rather than a library, so I can let it sit for a little while.

Where Next?

Popular in Questions Top

vertexbuffer
Hello, can anybody help here..? I have a list of players and I what to delete an element, but every for loop the list is reverting to ori...
New
ovidiubadita
Hey all, I discovered Elixir and I love it. I always wanted to learn a functional programming and I intended to go for Haskell, but afte...
New
jononomo
For some reason my phoenix channels are working for me in my local dev environment, but as soon as I deploy via Docker, I get a 403 error...
New
stefanchrobot
What’s the safe way to decode a JSON string into a struct? I want to avoid calling String.to_atom. Jason.decode can give me a map with st...
New
jay1
Why is it that the mnesia database isn’t the most preferred database for use in Elixir/Phoenix?
New
greenz1
I have a phoenix application from which a user can download multiple(5-6) files of size 1MB. I couldn’t find anything related to sending ...
New
Patoshizzle
After calling mix ecto.create I get this error: 17:00:32.162 [error] GenServer #PID<0.412.0> terminating ** (Postgrex.Error) FATAL...
New

Other popular topics Top

vertexbuffer
Hello, can anybody help here..? I have a list of players and I what to delete an element, but every for loop the list is reverting to ori...
New
joaquinalcerro
Hi there, I am working with Ecto-Postgresql and I need to call all of the records from a specific table but the table has 40,000 records...
New
lanycrost
Hi everyone! I need implement if…else if…else condition from my elixir code, and anymore of this control flow structures not work proper...
New
AstonJ
Seen any cool LiveView demos, sample apps or examples? Please post them here! :003:
New
sorentwo
Hello! tl;dr Announcing Oban, an Ecto based job processing library with a focus on reliability and historical observability. After spen...
985 44608 311
New
shijith.k
I am trying to start a new phoenix project with elixir 1.9, but mix phx.new does not work. It says that ** (Mix) The task "phx.new" could...
New

We're in Beta

About us Mission Statement