Gradualizer icon indicating copy to clipboard operation
Gradualizer copied to clipboard

Don't allow comparison of just anything

Open FrankBro opened this issue 5 years ago • 5 comments

I know this is a feature that is supported by Erlang and the documentation even explains how it works but I feel Gradualizer could figure out if something should be compared or no.

-spec test() -> boolean().
test() ->
    {cm, 42} < 43.
    

FrankBro avatar Jun 05 '20 17:06 FrankBro

We've had similar discussions elsewhere but it's good to have it again! I think we should not fail on this. It is a bit inefficient but it's not wrong. Could be the result of code generation!

Zalastax avatar Jun 05 '20 17:06 Zalastax

I think and always thought that we should allow this.

The total order of terms is used in things like balanced trees where the keys can be anything.

zuiderkwast avatar Jun 09 '20 12:06 zuiderkwast

Could we issue a different kind of warning possibly that needs to be enabled? Kind of like a pedantic flag?

FrankBro avatar Jun 09 '20 15:06 FrankBro

Perhaps we can add an option! This whole project is experimental and we have experimental options to tweak the behaviour already. It should affect all the comparisons operators then.

zuiderkwast avatar Jun 10 '20 14:06 zuiderkwast

Another thing which is more of a style preference is the use of orelse and andalso where the second operand is not a boolean. That is perfectly valid in Erlang, but some think it's wrong/bad. We could have an option for that too.

zuiderkwast avatar Jun 10 '20 14:06 zuiderkwast