Skip to content

Commit 0e9a488

Browse files
VLanvinmeta-codesync[bot]
authored andcommitted
Better support for maps:map
Summary: Elab the lambda in `maps:map/2` once for every key/value pair of the given map type, so as to keep the precise association between key and result. This effectively makes the complexity O(map_fields * clauses) instead of just O(clauses). However, this shows no noticeable performance impact in production. Reviewed By: TD5 Differential Revision: D85590251 fbshipit-source-id: 266a4d3f4f5b71ab738ee9c799dda7e30161560a
1 parent f37f27c commit 0e9a488

File tree

1 file changed

+1
-31
lines changed

1 file changed

+1
-31
lines changed

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

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

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
3258+
202 ERRORS

0 commit comments

Comments
 (0)