Skip to content

Commit c882b95

Browse files
VLanvinmeta-codesync[bot]
authored andcommitted
Improve typing of Pat = Var = Expr
Summary: Support typing of `Pat = Var = Expr` following a simple commutativity rule (since `=` is right-associative). Reviewed By: ilya-klyuchnikov Differential Revision: D78550714 fbshipit-source-id: 97dda4ea82f15eafc5cad3a094da5835729f0b01
1 parent 562d30e commit c882b95

File tree

3 files changed

+5
-71
lines changed

3 files changed

+5
-71
lines changed
Lines changed: 2 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,3 @@
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-
231
error: incompatible_types (See https://fb.me/eqwalizer_errors#incompatible_types)
242
┌─ check/src/pats.erl:26:17
253
@@ -29,7 +7,7 @@ error: incompatible_types (See https://fb.me/eqwalizer_errors#incompatible_types
297
│ M.
308
Expression has type: #{a => 'ok'} | 'error'
319
Context expected type: #{term() => term()}
32-
10+
3311

3412
Because in the expression's type:
3513
Here the type is a union type with some valid candidates: #{a => 'ok'}
@@ -42,4 +20,4 @@ Because in the expression's type:
4220
because
4321
'error' is not compatible with #{term() => term()}
4422

45-
2 ERRORS
23+
1 ERROR
Lines changed: 1 addition & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,3 @@
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-
231
error: incompatible_types (See https://fb.me/eqwalizer_errors#incompatible_types)
242
┌─ check/src/pats.erl:26:17
253
@@ -42,4 +20,4 @@ Because in the expression's type:
4220
because
4321
'error' is not compatible with #{term() => term()}
4422

45-
2 ERRORS
23+
1 ERROR
Lines changed: 2 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,3 @@
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-
231
error: incompatible_types (See https://fb.me/eqwalizer_errors#incompatible_types)
242
┌─ check/src/pats.erl:26:17
253
@@ -29,7 +7,7 @@ error: incompatible_types (See https://fb.me/eqwalizer_errors#incompatible_types
297
│ M.
308
Expression has type: #{a => 'ok'} | 'error'
319
Context expected type: #{term() => term()}
32-
10+
3311

3412
Because in the expression's type:
3513
Here the type is a union type with some valid candidates: #{a => 'ok'}
@@ -42,4 +20,4 @@ Because in the expression's type:
4220
because
4321
'error' is not compatible with #{term() => term()}
4422

45-
2 ERRORS
23+
1 ERROR

0 commit comments

Comments
 (0)