Skip to content
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

Unify type_check_expr and type_check_expr_in #574

Draft
wants to merge 29 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
96df82f
wip: Use subtype . type_check_expr in place of type_check_expr_in
erszcz Oct 11, 2024
a23106e
Fix test/should_fail/rigid_type_variables_fail.erl
erszcz Oct 11, 2024
2e0dd23
Fix test/known_problems/should_pass/binary_exhaustiveness_checking_sh…
erszcz Oct 14, 2024
ceb2655
Fix test/known_problems/should_fail/binary_comprehension.erl
erszcz Oct 14, 2024
02df3f0
Fix test/should_fail/return_fun_fail.erl
erszcz Oct 14, 2024
ba3a0b9
Fix test/known_problems/should_pass/fun_subtyping.erl
erszcz Oct 14, 2024
ca9094d
Fix test/known_problems/should_pass/refine_comparison_should_pass.erl
erszcz Oct 14, 2024
96c2b9b
Fix test/known_problems/should_pass/refine_bound_var_on_mismatch.erl
erszcz Oct 14, 2024
8ca1591
Fix test/should_fail/rel_op.erl
erszcz Oct 14, 2024
e9fd335
Check 'case' exhaustiveness in do_type_check_expr/2
erszcz Oct 14, 2024
e4145b6
Fix test/known_problems/should_fail/exhaustive_expr.erl
erszcz Oct 14, 2024
ee3f7ec
fixup! Check 'case' exhaustiveness in do_type_check_expr/2
erszcz Oct 14, 2024
ed50fec
Fix test/known_problems/should_fail/case_pattern_should_fail.erl
erszcz Oct 14, 2024
32b6a2c
fixup! wip: Use subtype . type_check_expr in place of type_check_expr_in
erszcz Oct 14, 2024
6102c5b
Fix test/should_fail/arith_op_fail.erl
erszcz Oct 14, 2024
89c3f4e
Check clauses against inferred type in do_type_check_expr/2
erszcz Oct 14, 2024
093af82
Fix test/should_pass/return_fun.erl
erszcz Oct 14, 2024
96f838b
fixup! Fix test/known_problems/should_pass/binary_exhaustiveness_chec…
erszcz Oct 14, 2024
b283f1a
Silence unnecessary Makefile echo output
erszcz Oct 14, 2024
37fa124
Fix test/should_pass/refine_bound_var_pass.erl
erszcz Oct 14, 2024
f097860
Fix test/should_pass/record_refinement.erl
erszcz Oct 14, 2024
f1b6e9c
Fix test/should_pass/qlc_test.erl
erszcz Oct 15, 2024
86a6c31
Fix test/should_pass/operator_subtypes.erl
erszcz Oct 15, 2024
68a4b8f
Fix test/should_pass/non_neg_plus_pos_is_pos_pass.erl
erszcz Oct 15, 2024
fa10bee
Fix test/should_pass/iodata.erl
erszcz Oct 15, 2024
390cdea
Fix test/should_pass/factorial.erl
erszcz Oct 15, 2024
d43dcbc
fixup! fixup! Fix test/known_problems/should_pass/binary_exhaustivene…
erszcz Oct 15, 2024
64c834c
TODO: reenable broken typechecker_tests
erszcz Oct 15, 2024
6210517
Reverse type order in the type_error
erszcz Oct 15, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions test/known_problems/should_pass/return_fun_should_pass.erl
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
-module(return_fun_should_pass).

-export([return_fun_intersection/0,
return_fun_union_intersection/0]).

-spec return_fun_intersection() -> fun((any()) -> integer()).
return_fun_intersection() -> fun number/1.

-spec return_fun_union_intersection()
-> fun((atom()) -> atom()) |
fun((1..3) -> integer()).
return_fun_union_intersection() -> fun number/1.

-spec number(integer()) -> integer();
(float()) -> float().
number(N) -> N.
17 changes: 4 additions & 13 deletions test/should_pass/return_fun.erl
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
-module(return_fun).

-compile([export_all, nowarn_export_all]).
-export([return_fun_term/0,
return_fun_fun/0,
return_fun_union/0,
return_fun_any_arity/0]).

-spec return_fun_term() -> term().
return_fun_term() -> fun nil/0.
Expand All @@ -14,17 +17,5 @@ return_fun_union() -> fun nil/0.
-spec return_fun_any_arity() -> fun((...) -> list()).
return_fun_any_arity() -> fun nil/0.

-spec return_fun_intersection() -> fun((any()) -> integer()).
return_fun_intersection() -> fun number/1.
Comment on lines -17 to -18
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know you just moved this function around, but why should this pass? The spec says that return_fun_intersection/0 returns a function that returns an integer, but it actually returns a function that can also return a float (if I pass it a float). A function that might return a float should not be a subtype of a function that returns an integer.


-spec return_fun_union_intersection()
-> fun((atom()) -> atom()) |
fun((1..3) -> integer()).
return_fun_union_intersection() -> fun number/1.
Comment on lines -20 to -23
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The same goes for this function.


-spec nil() -> [].
nil() -> [].

-spec number(integer()) -> integer();
(float()) -> float().
number(N) -> N.