Skip to content

Commit 217fa9a

Browse files
VLanvinmeta-codesync[bot]
authored andcommitted
Fix occurrence typing for record/tuple unions
Summary: Fix overlap calculation between record types and tuple types by adding an arity check. Reviewed By: TD5 Differential Revision: D85806277 fbshipit-source-id: ae17d5c157a1519994da1924542879c37566645a
1 parent 67416c1 commit 217fa9a

File tree

2 files changed

+2
-46
lines changed

2 files changed

+2
-46
lines changed

crates/elp/src/resources/test/eqwalizer_tests/eqwater/deep_tuples.pretty

Lines changed: 1 addition & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -30,26 +30,4 @@ error: incompatible_types (See https://fb.me/eqwalizer_errors#incompatible_types
3030
Expression has type: 'ok'
3131
Context expected type: none()
3232

33-
error: incompatible_types (See https://fb.me/eqwalizer_errors#incompatible_types)
34-
┌─ eqwater/src/deep_tuples.erl:38:19
35-
36-
38 │ test5({ok, V}) -> V.
37-
│ ^
38-
│ │
39-
│ V.
40-
Expression has type: 'a' | 'ok'
41-
Context expected type: 'ok'
42-
43-
44-
Because in the expression's type:
45-
Here the type is a union type with some valid candidates: 'ok'
46-
However the following candidate: 'a'
47-
Differs from the expected type: 'ok'
48-
49-
------------------------------ Detailed message ------------------------------
50-
51-
'a' | 'ok' is not compatible with 'ok'
52-
because
53-
'a' is not compatible with 'ok'
54-
55-
5 ERRORS
33+
4 ERRORS

crates/elp/src/resources/test/eqwalizer_tests/eqwater/eqwater.pretty

Lines changed: 1 addition & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -352,28 +352,6 @@ Because in the expression's type:
352352
because
353353
tuple() is not compatible with atom()
354354

355-
error: incompatible_types (See https://fb.me/eqwalizer_errors#incompatible_types)
356-
┌─ eqwater/src/eqwater.erl:681:18
357-
358-
681 │ {_N, _N1} -> X#one_field.f1
359-
│ ^
360-
│ │
361-
│ X.
362-
Expression has type: #one_field{} | #two_fields1{}
363-
Context expected type: #one_field{}
364-
365-
366-
Because in the expression's type:
367-
Here the type is a union type with some valid candidates: #one_field{}
368-
However the following candidate: #two_fields1{}
369-
Differs from the expected type: #one_field{}
370-
371-
------------------------------ Detailed message ------------------------------
372-
373-
#one_field{} | #two_fields1{} is not compatible with #one_field{}
374-
because
375-
#two_fields1{} is not compatible with #one_field{}
376-
377355
error: incompatible_types (See https://fb.me/eqwalizer_errors#incompatible_types)
378356
┌─ eqwater/src/eqwater.erl:839:27
379357
@@ -673,4 +651,4 @@ error: incompatible_types (See https://fb.me/eqwalizer_errors#incompatible_types
673651
Expression has type: fun((term(), term()) -> term())
674652
Context expected type: 'ok'
675653

676-
39 ERRORS
654+
38 ERRORS

0 commit comments

Comments
 (0)