I get the following warning from the dialyzer:
:0:unknown_type Unknown type: Access.get/2.
Unfortunately, there is no information wherein the code the problem is.
Does anyone have an idea of how to find the code that causes the warning?
Thank you in advance for your reply.
When exactly does it happen and do you have a project to reproduce. It might as well be a problem within one of your dependencies.
These are the hardest to track down. My kingdom for line numbers.
Depending on the size of the project, commenting out large sections and rerunning and whittling down is often the best way to find these. Similarly, doing something like a git bisect and finding when it was introduced. Those are much more manual debugging steps than I would like, and increase the friction of adopting Dialyzer, but that’s all Dialyzer gives us for that particular error, so we can’t really give more information, sadly.
You might accomplish your bisect with a regex Dialyzer ignore file for all errors that are not that specific error, then run git bisect til it shows up, to find the change that introduced the error. That would also help you find if a dependency introduced it somewhere, per the other comment.
The message suggests there’s someplace that’s trying to call
Access.get(some_container, :some_key) in a a type:
@type weird_type :: Access.get(some_container, :some_key)
This doesn’t seem like code anyone would write on purpose, but an error in quoting in a macro could produce this if the
Access.get call was supposed to happen at AST-generation time.
If it’s Access.get it might also be the result of doing something like foo
Thank you all. I have found the bug. I have made a mistake on rewriting a spec.
The wrong spec looked like:
@spec foo(t()[number()]) :: String.t()