Skip to content

Commit 9b265d7

Browse files
VLanvinfacebook-github-bot
authored andcommitted
Better scoring for map mismatches
Summary: Error messages should always choose a map with common keys if possible. The case where there are no keys in common was badly handled, leading to it being sometimes chosen. Reviewed By: TD5 Differential Revision: D69980751 fbshipit-source-id: f8f0b6893e023b7555ef9c5419a73295455b78c8
1 parent a5965ec commit 9b265d7

File tree

3 files changed

+7
-13
lines changed

3 files changed

+7
-13
lines changed

crates/elp/src/resources/test/eqwalizer_tests/check/custom.pretty

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -669,13 +669,6 @@ Expression has type: #{'a' | 'b' => atom() | number()}
669669
Context expected type: #{a := atom(), b := number()} | #{a := atom()}
670670
671671

672-
Because in the expression's type:
673-
Here the type is: #{...}
674-
Context expects type: #{a := ..., ...}
675-
The type of the expression is missing the following required keys: a.
676-
677-
------------------------------ Detailed message ------------------------------
678-
679672
#{'a' | 'b' => atom() | number()} is not compatible with #{a := atom(), b := number()} | #{a := atom()}
680673
because
681674
#{'a' | 'b' => atom() | number()} is not compatible with #{a := atom(), b := number()}

crates/elp/src/resources/test/eqwalizer_tests/check/error_messages.pretty

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,10 @@ Context expected type: foo_map() | #{foo => atom()}
1010
1111

1212
Because in the expression's type:
13-
Here the type is: #{baz := ...}
14-
Context expects type: #{...}
15-
The expected map has no corresponding key for: baz.
13+
#{ baz =>
14+
Here the type is: atom()
15+
Context expects type: number()
16+
, ... }
1617

1718
------------------------------ Detailed message ------------------------------
1819

crates/elp/src/resources/test/eqwalizer_tests/check/recursive_aliases.pretty

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -158,9 +158,9 @@ Context expected type: mChainA()
158158
159159

160160
Because in the expression's type:
161-
Here the type is: #{...}
162-
Context expects type: #{a := ..., ...}
163-
The type of the expression is missing the following required keys: a.
161+
Here the type is: #{b := mChainB()}
162+
Context expects type: 'nil' | #{a := mChainA()}
163+
No candidate matches in the expected union.
164164

165165
------------------------------ Detailed message ------------------------------
166166

0 commit comments

Comments
 (0)