Skip to content

Commit

Permalink
Ad-hoc handling of is_float/is_integer guards
Browse files Browse the repository at this point in the history
Summary:
In the very specific case
```Erlang
foo(I) when is_integer(I) -> ...
foo(F) when is_float(F) -> ...
```
ignore negative type info issued from the former clause in occurrence typing, so as to avoid a falsely empty type in the latter.

The logic is based around comparing the current guard with the following ones, if it is of the form `is_integer` or `is_float` and the dual is present after, then the negative info is ignored.
This negative info will however be kept after the second guard, so as to still properly refine number types.

This needs some comparison of variables, so the code had to be refactored to keep the alias maps available for every clause.

Reviewed By: ilya-klyuchnikov

Differential Revision: D59518988

fbshipit-source-id: 7af4233d48ea0b8c28b2a4c79fc381cec9c6ed87
  • Loading branch information
VLanvin authored and facebook-github-bot committed Jul 9, 2024
1 parent fae41b5 commit 6622118
Showing 1 changed file with 1 addition and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,20 +38,4 @@ error: clause_not_covered

See https://fb.me/eqwalizer_errors#clause_not_covered

error: clause_not_covered
┌─ options/src/uncovered_clauses.erl:37:1
37 │ uncovered_number(F) when is_float(F) -> ok;
│ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Clause is not covered by spec

See https://fb.me/eqwalizer_errors#clause_not_covered

error: clause_not_covered
┌─ options/src/uncovered_clauses.erl:42:1
42 │ uncovered_number_2(I) when is_integer(I) -> ok;
│ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Clause is not covered by spec

See https://fb.me/eqwalizer_errors#clause_not_covered

7 ERRORS
5 ERRORS

0 comments on commit 6622118

Please sign in to comment.