Gradualizer icon indicating copy to clipboard operation
Gradualizer copied to clipboard

Frustrating missing exports before OTP 23

Open FrankBro opened this issue 5 years ago • 2 comments

I came twice across this and it's a pretty frustrating experience: OTP finally exporting types/functions since 23. The examples I've seen so far:

  • supervisor's startlink_ret type
  • erlang's operators (in the form erlang:'+'/2)

Right now, I am using OTP 22 so gradualizer complain if I use these. Is there a considerable fix for this? I noticed we overload some functions in the erlang.specs.erl and lists.specs.erl (although, I can't find any reference to those files anymore 🤔), should we try to rip newer specs and check them in?

My line of thought is imagine your project passing gradualizer and then you switch computer and it doesn't pass anymore. Frustrating user experience for sure.

Any ideas?

FrankBro avatar Oct 28 '20 23:10 FrankBro

The *.specs.erl files are loaded by default using gradualizer_prelude.erl which is compiled using a parse transform. These specs exist mostly because our types and specs have slightly different semantics compared to dialyzer's.

It's possible to add more specs and types here. I think it would be good if e.g. A + B could be handled in the same way as erlang:'+'(A, B), but currently functions and operators are not handled in the same way. I think we have logic for + which maybe corresponds to something like

integer() + integer() -> integer();
float() + integer() -> float();
integer() + float() -> float();
float() + float() -> float().

Maybe we even have logic saying that positive integers are closed under addition and other even more complex things. I don't remember.

zuiderkwast avatar Oct 29 '20 00:10 zuiderkwast

Yea, I remember playing in the constraint part and it has integer ranges and such. So truly that's the best way, add whatever I find missing.

FrankBro avatar Oct 29 '20 00:10 FrankBro