svetigrah
Greetings. I have a problem with dialyxir (0.5, elixir 1.5).
The usecase is this:
from(x in SomeModule)
|> function1()
|> function2()
|> limit(10)
|> function3()
I want to give the functions @specs, but here’s the problem:
@spec function1(Ecto.Query.t) :: Ecto.Query.t raises a dialyzer error:
The call 'Elixir.Pop.Search':add_tag_filters(#{'__struct__':='Elixir.Ecto.Query', 'assocs':=[], 'distinct':='nil', 'from':={'nil' | <<_:64>> | ['author' | 'author_id' | 'contents' | 'id' | 'inserted_at' | 'is_disabled' | 'is_pending' | 'l10n' | 'search'
| 'tag_ids' | 'type' | 'updated_at' | {'inserted_at',{'Elixir.Ecto.Schema','__timestamps__',[any(),...]}} | {'updated_at',{'Elixir.Ecto.Schema','__timestamps__',[any(),...]}}] | 130233438 | {'id','id'} | #{'__struct__'=>'Elixir.Ecto.Query', 'assocs'=>[], 'author_id'=>'id', 'contents
'=>'map', 'distinct'=>'nil', 'from'=>{<<_:64>>,'Elixir.Pop.Library.Resource'}, 'group_bys'=>[], 'havings'=>[], 'id'=>'id', 'inserted_at'=>'utc_datetime', 'is_disabled'=>'boolean', 'is_pending'=>'boolean', 'joins'=>[], 'l10n'=>{'array','map'}, 'limit'=>'nil', 'lock'=>'nil', 'offset'=>
'nil', 'order_bys'=>[], 'prefix'=>'nil', 'preloads'=>[], 'search'=>'map', 'select'=>'nil', 'sources'=>'nil', 'tag_ids'=>{'array','integer'}, 'type'=>'string', 'updated_at'=>'utc_datetime', 'updates'=>[], 'wheres'=>[]},'Elixir.Pop.Library.Resource'}, 'group_bys':=[], 'havings':=[], 'j
oins':=[], 'limit':='nil', 'lock':='nil', 'offset':='nil', 'order_bys':=[], 'prefix':='nil' | <<_:64>> | ['author' | 'author_id' | 'contents' | 'id' | 'inserted_at' | 'is_disabled' | 'is_pending' | 'l10n' | 'search' | 'tag_ids' | 'type' | 'updated_at' | {'inserted_at',{'Elixir.Ecto.S
chema','__timestamps__',[any(),...]}} | {'updated_at',{'Elixir.Ecto.Schema','__timestamps__',[any(),...]}}] | 130233438 | {'id','id'} | #{'__struct__'=>'Elixir.Ecto.Query', 'assocs'=>[], 'author_id'=>'id', 'contents'=>'map', 'distinct'=>'nil', 'from'=>{<<_:64>>,'Elixir.Pop.Library.Re
source'}, 'group_bys'=>[], 'havings'=>[], 'id'=>'id', 'inserted_at'=>'utc_datetime', 'is_disabled'=>'boolean', 'is_pending'=>'boolean', 'joins'=>[], 'l10n'=>{'array','map'}, 'limit'=>'nil', 'lock'=>'nil', 'offset'=>'nil', 'order_bys'=>[], 'prefix'=>'nil', 'preloads'=>[], 'search'=>'m
ap', 'select'=>'nil', 'sources'=>'nil', 'tag_ids'=>{'array','integer'}, 'type'=>'string', 'updated_at'=>'utc_datetime', 'updates'=>[], 'wheres'=>[]}, 'preloads':=[], 'select':='nil', 'sources':='nil', 'updates':=[], 'wheres':=[#{'__struct__':='Elixir.Ecto.Query.BooleanExpr', 'expr':=
{'and',[],[{'==',[],[{{'.',[],['is_disabled' | 'is_pending' | {'&',[],[0,...]},...]},[],[]} | #{'__struct__':='Elixir.Ecto.Query.Tagged', 'tag':='nil', 'type':={0,'is_disabled' | 'is_pending'}, 'value':='false'},...]},...]}, 'file':=<<_:432>>, 'line':=10, 'op':='and', 'params':=[]},.
..]},tags@1::any()) does not have an opaque term of type 'Elixir.Ecto.Query':t() as 1st argument
This won’t happen with function2 though:
@spec function2(Ecto.Query.t) :: Ecto.Query.t
but will happen again with function3:
@spec function3(Ecto.Query.t) :: Ecto.Query.t
Note that functions alter query in a way, say, pipe it through where or whatever.
Any idea why the first and third @specs aren’t good?
Trending in Questions
Hello!
Suppose you are building workflow (order / task / payment) processing system with the following requirements:
Each workflow con...
New
I’m in search of an Elixir library that offers PDF generation capabilities similar to Ruby’s Prawn. While there have been discussions abo...
New
I’m looking to build a personal workflow to quickly deploy web applications written in elixir/phoenix, for local consumption (ie not on t...
New
Before I dive in myself, did anyone successfully sprinkle Hologram into their existing LiveView app?
Looking for hints regarding:
Addi...
New
Kia ora,
We have been using elixir-google-api to connect to Google Drive. However, with the updates to Tesla due to CVEs this is now bro...
New
Hi all, I wanted to ask how the community is dealing with post-release steps.
Today we have Ecto migrations, which make sure that the db...
New
Hello,
I have an Elixir backend that implements a custom protocol over TCP. I want to load test the backend and assess the performance o...
New
Other Trending Topics
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
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
Hello everyone. After busy few months I am happy to announce v0.1.0 of Emerge & Solve.
They are GUI (Emerge) and State management (S...
New
Corex is an accessible, unstyled UI component library for Phoenix that integrates Zag.js state machines using Vanilla JavaScript and Live...
New
Emily is an Elixir library that runs Nx computations on Apple’s MLX. Install it as the default Nx backend and Nx, defn, Axon, Nx.Serving,...
New
There are three potential reasons for members of this forum to have a look at https://vutuv.de
You are tired or annoyed of LinkedIn.
Yo...
New
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #deployment
- #library
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #channels
- #elixirconf
- #exunit
- #discussion
- #code-sync
- #javascript
- #podcasts
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixir-ls
- #blog-post
- #phoenix_html
- #iex
- #graphql
- #ai
- #genstage
- #elixirconf-us
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #api
- #forms
- #metaprogramming
- #security
- #hex










First 9 of 9 Posts
NobbZ
From is a macro and creates a literal of the struct, therefore dialyzer sees the opacity violated. Limit is a macro as well and makes dialyzer think you were fiddling with the internals of the struct on your own, therefore it seems opacity violated.
svetigrah
Why is
@specforfunction2valid then, if it uses a macro as well in its function body, e.gwhere(query, ....).Actually, this is the same for
function1’s return value as well, as this is valid:@spec function1(any()) :: Ecto.Query.t.NobbZ
The specs for your functions seem to be valid, dialyzer complains about the calls.
will probably be fine.
Unless you are running the query in
function3/1, you can also swap the ordering:svetigrah
Unfortunately, this does not solve the issue, error messages remain the same.
NobbZ
I think I can see why it doesn’t for function1… But it remains for 3 as well when reordering calls?
svetigrah
Oh, sorry, yes, it does work for 3, because of reordering.
NobbZ
I have taken the freedom to actually post a bug report at ecto:
https://github.com/elixir-ecto/ecto/issues/2151
svetigrah
Nice, thanks.
NobbZ
It got fixed today, so once the next version gets released it should be fine.