File tree Expand file tree Collapse file tree 4 files changed +166
-0
lines changed
crates/elp/src/resources/test/eqwalizer_tests/check
test_projects/eqwalizer_tests/check/src Expand file tree Collapse file tree 4 files changed +166
-0
lines changed Original file line number Diff line number Diff line change 1+ error: incompatible_types (See https://fb.me/eqwalizer_errors#incompatible_types)
2+ ┌─ check/src/pats.erl:21:17
3+ │
4+ 21 │ maps:get(a, M).
5+ │ ^
6+ │ │
7+ │ M.
8+ Expression has type: #{a => 'ok'} | 'error'
9+ Context expected type: #{term() => term()}
10+ │
11+
12+ Because in the expression's type:
13+ Here the type is a union type with some valid candidates: #{a => 'ok'}
14+ However the following candidate: 'error'
15+ Differs from the expected type: #{term() => term()}
16+
17+ ------------------------------ Detailed message ------------------------------
18+
19+ #{a => 'ok'} | 'error' is not compatible with #{term() => term()}
20+ because
21+ 'error' is not compatible with #{term() => term()}
22+
23+ error: incompatible_types (See https://fb.me/eqwalizer_errors#incompatible_types)
24+ ┌─ check/src/pats.erl:26:17
25+ │
26+ 26 │ maps:get(a, M).
27+ │ ^
28+ │ │
29+ │ M.
30+ Expression has type: #{a => 'ok'} | 'error'
31+ Context expected type: #{term() => term()}
32+ │
33+
34+ Because in the expression's type:
35+ Here the type is a union type with some valid candidates: #{a => 'ok'}
36+ However the following candidate: 'error'
37+ Differs from the expected type: #{term() => term()}
38+
39+ ------------------------------ Detailed message ------------------------------
40+
41+ #{a => 'ok'} | 'error' is not compatible with #{term() => term()}
42+ because
43+ 'error' is not compatible with #{term() => term()}
44+
45+ 2 ERRORS
Original file line number Diff line number Diff line change 1+ error: incompatible_types (See https://fb.me/eqwalizer_errors#incompatible_types)
2+ ┌─ check/src/pats.erl:21:17
3+ │
4+ 21 │ maps:get(a, M).
5+ │ ^
6+ │ │
7+ │ M.
8+ Expression has type: #{a => 'ok'} | 'error'
9+ Context expected type: #{term() => term()}
10+ │
11+
12+ Because in the expression's type:
13+ Here the type is a union type with some valid candidates: #{a => 'ok'}
14+ However the following candidate: 'error'
15+ Differs from the expected type: #{term() => term()}
16+
17+ ------------------------------ Detailed message ------------------------------
18+
19+ #{a => 'ok'} | 'error' is not compatible with #{term() => term()}
20+ because
21+ 'error' is not compatible with #{term() => term()}
22+
23+ error: incompatible_types (See https://fb.me/eqwalizer_errors#incompatible_types)
24+ ┌─ check/src/pats.erl:26:17
25+ │
26+ 26 │ maps:get(a, M).
27+ │ ^
28+ │ │
29+ │ M.
30+ Expression has type: #{a => 'ok'} | 'error'
31+ Context expected type: #{term() => term()}
32+ │
33+
34+ Because in the expression's type:
35+ Here the type is a union type with some valid candidates: #{a => 'ok'}
36+ However the following candidate: 'error'
37+ Differs from the expected type: #{term() => term()}
38+
39+ ------------------------------ Detailed message ------------------------------
40+
41+ #{a => 'ok'} | 'error' is not compatible with #{term() => term()}
42+ because
43+ 'error' is not compatible with #{term() => term()}
44+
45+ 2 ERRORS
Original file line number Diff line number Diff line change 1+ error: incompatible_types (See https://fb.me/eqwalizer_errors#incompatible_types)
2+ ┌─ check/src/pats.erl:21:17
3+ │
4+ 21 │ maps:get(a, M).
5+ │ ^
6+ │ │
7+ │ M.
8+ Expression has type: #{a => 'ok'} | 'error'
9+ Context expected type: #{term() => term()}
10+ │
11+
12+ Because in the expression's type:
13+ Here the type is a union type with some valid candidates: #{a => 'ok'}
14+ However the following candidate: 'error'
15+ Differs from the expected type: #{term() => term()}
16+
17+ ------------------------------ Detailed message ------------------------------
18+
19+ #{a => 'ok'} | 'error' is not compatible with #{term() => term()}
20+ because
21+ 'error' is not compatible with #{term() => term()}
22+
23+ error: incompatible_types (See https://fb.me/eqwalizer_errors#incompatible_types)
24+ ┌─ check/src/pats.erl:26:17
25+ │
26+ 26 │ maps:get(a, M).
27+ │ ^
28+ │ │
29+ │ M.
30+ Expression has type: #{a => 'ok'} | 'error'
31+ Context expected type: #{term() => term()}
32+ │
33+
34+ Because in the expression's type:
35+ Here the type is a union type with some valid candidates: #{a => 'ok'}
36+ However the following candidate: 'error'
37+ Differs from the expected type: #{term() => term()}
38+
39+ ------------------------------ Detailed message ------------------------------
40+
41+ #{a => 'ok'} | 'error' is not compatible with #{term() => term()}
42+ because
43+ 'error' is not compatible with #{term() => term()}
44+
45+ 2 ERRORS
Original file line number Diff line number Diff line change 1+ % %% Copyright (c) Meta Platforms, Inc. and affiliates. All rights reserved.
2+ % %%
3+ % %% This source code is licensed under the Apache 2.0 license found in
4+ % %% the LICENSE file in the root directory of this source tree.
5+
6+ -module (pats ).
7+
8+ -compile ([export_all , nowarn_export_all ]).
9+
10+ -spec return_map () -> #{a => ok } | error .
11+ return_map () -> #{a => ok }.
12+
13+ -spec patmatch1 () -> ok .
14+ patmatch1 () ->
15+ #{a := V } = _M = return_map (),
16+ V .
17+
18+ -spec patmatch2 () -> ok .
19+ patmatch2 () ->
20+ #{a := _V } = M = return_map (),
21+ maps :get (a , M ).
22+
23+ -spec patmatch3_neg () -> ok .
24+ patmatch3_neg () ->
25+ _V = M = return_map (),
26+ maps :get (a , M ).
27+
28+ -spec patmatch4 () -> ok .
29+ patmatch4 () ->
30+ M = #{a := _V } = return_map (),
31+ maps :get (a , M ).
You can’t perform that action at this time.
0 commit comments