Skip to content

Commit

Permalink
a bug repro
Browse files Browse the repository at this point in the history
Summary: - `apply_id_pred` is expected to be accepted, but it's rejected

Reviewed By: VLanvin

Differential Revision: D42401557

fbshipit-source-id: f9fc20150a4f93bf3dc984d6cb435478619b1e99
  • Loading branch information
ilya-klyuchnikov authored and facebook-github-bot committed Jan 9, 2023
1 parent 293e543 commit fb2201c
Show file tree
Hide file tree
Showing 6 changed files with 58 additions and 16 deletions.
24 changes: 12 additions & 12 deletions eqwalizer/test_projects/_cli/checkable_funs.cli
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
all funs:
All : 2877
Checkable : 2622
Well-typed checkable : 1677
All : 2879
Checkable : 2624
Well-typed checkable : 1678
Checkable ratio : 91%
Health ratio of checkable : 64%
error count : 944
error count : 945

--------------------------------------------
generated funs:
Expand All @@ -26,19 +26,19 @@ generated non-test funs:

--------------------------------------------
non-generated funs:
All : 2877
Checkable : 2622
Well-typed checkable : 1677
All : 2879
Checkable : 2624
Well-typed checkable : 1678
Checkable ratio : 91%
Health ratio of checkable : 64%
error count : 944
error count : 945

--------------------------------------------
non-generated non-test funs (most important):
All : 2875
Checkable : 2620
Well-typed checkable : 1676
All : 2877
Checkable : 2622
Well-typed checkable : 1677
Checkable ratio : 91%
Health ratio of checkable : 64%
error count : 943
error count : 944

4 changes: 2 additions & 2 deletions eqwalizer/test_projects/_cli/discarded_specs.cli
Original file line number Diff line number Diff line change
Expand Up @@ -42,5 +42,5 @@ type_aliases:uses_trans_unbound_var/2
type_aliases:uses_ty_w_unbound_var/2
type_aliases:uses_ty_w_unbound_var2/0
Discarded specs: 42
Total specs: 2750
Discarded ratio: 1.5273 %
Total specs: 2752
Discarded ratio: 1.5262 %
2 changes: 1 addition & 1 deletion eqwalizer/test_projects/_cli/long_errors.cli
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
Average error message length: 22.352245 characters
Average error message length: 22.345926 characters
Longest error message: 122 characters
Average error message length for the longest 10% of error msgs: 47.61905 characters
4 changes: 3 additions & 1 deletion eqwalizer/test_projects/_cli/misc.json
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,9 @@
"constant_f/1",
"apply_f/1",
"hd_contravariant/1",
"test_contravariant/0"
"test_contravariant/0",
"id_pred/1",
"apply_id_pred/1"
]
},
{
Expand Down
15 changes: 15 additions & 0 deletions eqwalizer/test_projects/check/src/contravariant.erl
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,13 @@ contravariant_subtype_neg(F) -> F.
-type runnable(A) :: fun((A) -> ok).
-type id(A) :: fun((A) -> A).

-type next(A) ::
eos | {head, A}.

-type pred(A) ::
{check, fun((next(A)) -> pred(A))}
| stop.

-spec log(term()) -> ok.
log(Thing) ->
io:format("~p~n", [Thing]).
Expand Down Expand Up @@ -146,3 +153,11 @@ hd_contravariant([F | _]) -> F.

-spec test_contravariant() -> (predicate(term())).
test_contravariant() -> hd_contravariant([]).

-spec id_pred
(pred(A)) -> pred(A).
id_pred(P) -> P.

-spec apply_id_pred
(pred(number())) -> pred(number()).
apply_id_pred(P) -> id_pred(P).
25 changes: 25 additions & 0 deletions eqwalizer/test_projects/check/src/contravariant.erl.check
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,13 @@ contravariant_subtype_neg(F) -> F. | ERROR | F.
-type runnable(A) :: fun((A) -> ok). | |
-type id(A) :: fun((A) -> A). | |
| |
-type next(A) :: | |
eos | {head, A}. | |
| |
-type pred(A) :: | |
{check, fun((next(A)) -> pred(A))} | |
| stop. | |
| |
-spec log(term()) -> ok. | |
log(Thing) -> | OK |
io:format("~p~n", [Thing]). | |
Expand Down Expand Up @@ -173,3 +180,21 @@ hd_contravariant([F | _]) -> F. | OK |
| |
-spec test_contravariant() -> (predicate(t…… |
test_contravariant() -> hd_contravariant([…… OK |
| |
-spec id_pred | |
(pred(A)) -> pred(A). | |
id_pred(P) -> P. | OK |
| |
-spec apply_id_pred | |
(pred(number())) -> pred(number()). | |
apply_id_pred(P) -> id_pred(P). | ERROR | P.
| | Expected: pred(A)
| | Got : pred(number())
| |
| | pred(number()) is not a subtype of pred(A)
| | because
| | {'check', fun((next(number())) -> pred(number()))} | 'stop' is not a subtype of pred(A)
| | because
| | {'check', fun((next(number())) -> pred(number()))} | 'stop' is not a subtype of {'check', fun((next(A)) -> pred(A))} | 'stop'
| | because
| | {'check', fun((next(number())) -> pred(number()))} is not a subtype of {'check', fun((next(A)) -> pred(A))} | 'stop'

0 comments on commit fb2201c

Please sign in to comment.