-
Notifications
You must be signed in to change notification settings - Fork 3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Can’t define type “product()” in OTP 26.0.2 #7584
Comments
iirc, this happened to me when I updated to OTP 26 from OTP 25, and I didn't clear my build artefacts and PLT. If you completely rebuild your code from scratch and create a new PLT, do you still see this error? If this is indeed a backwards compatibility issue with OTP 26, a change to make any Dialyzer modifications invalidate the PLT, like: -spec implementation_module_paths() -> module_file_path_lookup().
implementation_module_paths() ->
Dir = code:lib_dir(dialyzer),
Files1 = filelib:wildcard("**/ebin/**.beam",Dir),
Files2 = [filename:join([Dir, F]) || F <- Files1],
#{beam_file_to_module(File) => File || File <- Files2}. in dialyzer_iplt.erl and dialyzer_cplt.erl might help? Possibly also something similar for changes to the core erlang representation too. |
FWIW @TD5 I tried this work-around, no go. |
I used clean machine without OTP 25 (I have installed only OTP 26) and error happens always with and without "_build" directory and other artifacts. |
I notice you're using One way to see whether that is the case would be by running Dialyzer without rebar3 to see whether that works, e.g.: # Delete any existing PLT from the default location, e.g. something like rm `$HOME/.cache/erlang/*plt`
dialyzer --incremental --apps dialyzer stdlib kernel crypto compiler If this fails with the same error, then I am confident this is a bug in OTP. If this doesn't fail with that error, I suspect it's to do with an out-of-date PLT or My gut says this is related to N.B. if this is determined to be an issue of incompatible artefacts coming from |
It may also be worth clearing your global |
Right, I blew everything away, I'm happy to double check. I also tried with just dialyzer (to be clear it blows up trying to build the plt, not update or or use it). Edit: $ ls /Users/me/Library/Caches/erlang/
$ ^ nothing $ dialyzer --build_plt _build/default/lib/whoops/ebin/
Creating PLT /Users/me/Library/Caches/erlang/.dialyzer_plt ...
dialyzer: Analysis failed with error:
whoops.erl:7:2: Unable to find type 'fun'/2
Last messages in the log cache:
Reading files and computing callgraph... done in 0.03 secs
Removing edges... done in 0.00 secs So this seems like something goes wrong in going through the abstract code in building the initial plt. I'm happy to look further (provided I can find the time). |
Here's a simple reference that shows the issue: https://github.com/paulo-ferraz-oliveira/setup-beam-example/actions/runs/5978380986/job/16220351170. Erlang/OTP is installed alongside ===> Error in dialyzing apps: Analysis failed with error:
Unable to find type 'fun'/2 There's no cache involved, in this example, and the instance is clear of PLTs (well at least before the @TD5, I also run your suggestion for incremental Dialyzer, but it fails (not sure if that's what's causing the overall failure with lots of |
Not sure if it helps, but there's a few mentions to |
I couldn't find any issues directly related to this problem. To be clear |
I know it's not new 👍 but something changed around this particular word, so I'm just curious. |
I knew you did, just for other reads who come along 😄 FWIW, I did some manual CI and found that in the latest patch of OTP 25, we're good, no issue. This started in OTP-26-rc1. |
I narrowed this down to two commits :
Without actually going through the code, I can not say why, I will probably look at this later as it interests me 😄 |
I found the problem, it's arguable where it should be fixed, but here's one patch that would work :
Less fancier than what I had originally thought, but I got to know dialyzer code more! 😄 |
…-type/GH-7584/OTP-18738 dialyzer: Handle definition of type product/0
Describe the bug
Hello! I have a strange behaviour of dialyzer.
When I try to create type
product()
then dialyzer reported an error:To Reproduce
To reproduce you can use example:
If you remove
-spec
for functiontest
, then error will not reproduce.Affected versions
I use Erlang/OTP 26.0.2 (installed from
esl-erlang_26.0.2-1~debian~buster_amd64.deb
) on Debian 10 with rebar3 v.3.22.1Additional context
First of all I asked on the forum and the people have confirmed the same behaviour. So I think it looks like a bug.
Unfortunately I don't know the code of dialyzer and can't create a PR. Sorry for that.
The text was updated successfully, but these errors were encountered: