Skip to content

Commit 0b0dfa5

Browse files
VLanvinmeta-codesync[bot]
authored andcommitted
Fix occurrence typing for is_function/2
Summary: The actual top type for a function of arity `n` is `FunType(Nil, List.fill(n)(NoneType), AnyType)`, not `FunType(Nil, List.fill(n)(AnyType), AnyType)`, which means the negation of the predicate is not properly computed. However, due to how intersection is computed (and particularly when it involves dynamic types), using this as a top type for the positive refinement leads to confusing signal, producing `none()` as domain. So this diff only uses it for the negative part. Reviewed By: michalmuskala Differential Revision: D85336038 fbshipit-source-id: 663393fe5919274c945435e764132faa4b0e7221
1 parent 379bfd6 commit 0b0dfa5

File tree

1 file changed

+1
-45
lines changed

1 file changed

+1
-45
lines changed

crates/elp/src/resources/test/eqwalizer_tests/eqwater/eqwater-OTP-27.pretty

Lines changed: 1 addition & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -680,28 +680,6 @@ error: incompatible_types (See https://fb.me/eqwalizer_errors#incompatible_types
680680
Expression has type: number()
681681
Context expected type: 'ok'
682682

683-
error: incompatible_types (See https://fb.me/eqwalizer_errors#incompatible_types)
684-
┌─ eqwater/src/eqwater.erl:1306:18
685-
686-
1306 │ negate_fun(F) -> F.
687-
│ ^
688-
│ │
689-
│ F.
690-
Expression has type: fun((number(), number()) -> term()) | 'ok'
691-
Context expected type: 'ok'
692-
693-
694-
Because in the expression's type:
695-
Here the type is a union type with some valid candidates: 'ok'
696-
However the following candidate: fun((number(), number()) -> term())
697-
Differs from the expected type: 'ok'
698-
699-
------------------------------ Detailed message ------------------------------
700-
701-
fun((number(), number()) -> term()) | 'ok' is not compatible with 'ok'
702-
because
703-
fun((number(), number()) -> term()) is not compatible with 'ok'
704-
705683
error: incompatible_types (See https://fb.me/eqwalizer_errors#incompatible_types)
706684
┌─ eqwater/src/eqwater.erl:1309:45
707685
@@ -710,26 +688,4 @@ error: incompatible_types (See https://fb.me/eqwalizer_errors#incompatible_types
710688
Expression has type: fun((term(), term()) -> term())
711689
Context expected type: 'ok'
712690

713-
error: incompatible_types (See https://fb.me/eqwalizer_errors#incompatible_types)
714-
┌─ eqwater/src/eqwater.erl:1310:22
715-
716-
1310 │ negate_fun_neg(F) -> F.
717-
│ ^
718-
│ │
719-
│ F.
720-
Expression has type: fun((number(), number()) -> term()) | 'ok'
721-
Context expected type: 'ok'
722-
723-
724-
Because in the expression's type:
725-
Here the type is a union type with some valid candidates: 'ok'
726-
However the following candidate: fun((number(), number()) -> term())
727-
Differs from the expected type: 'ok'
728-
729-
------------------------------ Detailed message ------------------------------
730-
731-
fun((number(), number()) -> term()) | 'ok' is not compatible with 'ok'
732-
because
733-
fun((number(), number()) -> term()) is not compatible with 'ok'
734-
735-
41 ERRORS
691+
39 ERRORS

0 commit comments

Comments
 (0)