Skip to content

Commit f37f27c

Browse files
VLanvinmeta-codesync[bot]
authored andcommitted
Snapshot tests -- better maps:map/2
Summary: A snapshot test for more precise support of `maps:map/2` Reviewed By: RobinMorisset Differential Revision: D85677708 fbshipit-source-id: 1520e78419c51ae26604768fd78d787e06301a61
1 parent 52857fb commit f37f27c

File tree

2 files changed

+41
-1
lines changed

2 files changed

+41
-1
lines changed

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

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3255,4 +3255,34 @@ error: incompatible_types (See https://fb.me/eqwalizer_errors#incompatible_types
32553255
Expression has type: number()
32563256
Context expected type: binary()
32573257

3258-
202 ERRORS
3258+
error: incompatible_types (See https://fb.me/eqwalizer_errors#incompatible_types)
3259+
┌─ check/src/custom.erl:2722:5
3260+
3261+
2722 │ ╭ ╭ maps:map(fun
3262+
2723 │ │ │ (ka, va) -> va2;
3263+
2724 │ │ │ (_K, V) -> V
3264+
2725 │ │ │ end, M).
3265+
│ ╰─│───────────^ maps:map(fun, M).
3266+
Expression has type: #{ka => 'va' | 'vb' | 'vc' | 'va2', kb => 'va' | 'vb' | 'vc' | 'va2', kc => 'va' | 'vb' | 'vc' | 'va2'}
3267+
Context expected type: #{ka => 'va2', kb => 'vb', kc => 'vc'}
3268+
│ ╰───────────'
3269+
3270+
Because in the expression's type:
3271+
#{ ka =>
3272+
Here the type is a union type with some valid candidates: 'va2'
3273+
However the following candidate: 'va'
3274+
Differs from the expected type: 'va2'
3275+
, ... }
3276+
3277+
------------------------------ Detailed message ------------------------------
3278+
3279+
#{ka => 'va' | 'vb' | 'vc' | 'va2', kb => 'va' | 'vb' | 'vc' | 'va2', kc => 'va' | 'vb' | 'vc' | 'va2'} is not compatible with #{ka => 'va2', kb => 'vb', kc => 'vc'}
3280+
because
3281+
at key `ka`:
3282+
#{ka => 'va' | 'vb' | 'vc' | 'va2', kb => 'va' | 'vb' | 'vc' | 'va2', kc => 'va' | 'vb' | 'vc' | 'va2'} is not compatible with #{ka => 'va2', kb => 'vb', kc => 'vc'}
3283+
because
3284+
'va' | 'vb' | 'vc' | 'va2' is not compatible with 'va2'
3285+
because
3286+
'va' is not compatible with 'va2'
3287+
3288+
203 ERRORS

test_projects/eqwalizer_tests/check/src/custom.erl

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2713,3 +2713,13 @@ maps_foreach_neg(M) ->
27132713
end,
27142714
M
27152715
).
2716+
2717+
-spec maps_map_2_13(
2718+
#{ka => va, kb => vb, kc => vc}
2719+
) ->
2720+
#{ka => va2, kb => vb, kc => vc}.
2721+
maps_map_2_13(M) ->
2722+
maps:map(fun
2723+
(ka, va) -> va2;
2724+
(_K, V) -> V
2725+
end, M).

0 commit comments

Comments
 (0)