mirror of
https://github.com/CatalaLang/catala.git
synced 2024-11-08 17:10:22 +03:00
Fixed typing error
This commit is contained in:
parent
1494048869
commit
9c795b5010
@ -78,12 +78,19 @@ let rec unify (t1 : typ Pos.marked UnionFind.elem) (t2 : typ Pos.marked UnionFin
|
||||
unify t11 t21;
|
||||
unify t12 t22;
|
||||
None
|
||||
| (TTuple ts1, _), (TTuple ts2, _) ->
|
||||
List.iter2 unify ts1 ts2;
|
||||
None
|
||||
| (TEnum ts1, _), (TEnum ts2, _) ->
|
||||
List.iter2 unify ts1 ts2;
|
||||
None
|
||||
| (TTuple ts1, t1_pos), (TTuple ts2, t2_pos) | (TEnum ts1, t1_pos), (TEnum ts2, t2_pos) ->
|
||||
if List.length ts1 = List.length ts2 then begin
|
||||
List.iter2 unify ts1 ts2;
|
||||
None
|
||||
end
|
||||
else
|
||||
Errors.raise_multispanned_error
|
||||
(Format.asprintf "Error during typechecking, types %a and %a are incompatible"
|
||||
format_typ t1 format_typ t2)
|
||||
[
|
||||
(Some (Format.asprintf "Type %a coming from expression:" format_typ t1), t1_pos);
|
||||
(Some (Format.asprintf "Type %a coming from expression:" format_typ t2), t2_pos);
|
||||
]
|
||||
| (TArray t1', _), (TArray t2', _) ->
|
||||
unify t1' t2';
|
||||
None
|
||||
|
29
tests/test_enum/quick_pattern_2.catala
Normal file
29
tests/test_enum/quick_pattern_2.catala
Normal file
@ -0,0 +1,29 @@
|
||||
@Article@
|
||||
|
||||
/*
|
||||
new enum E:
|
||||
-- Case1 content int
|
||||
-- Case2
|
||||
|
||||
new enum F:
|
||||
-- Case3
|
||||
|
||||
new scope A:
|
||||
param x content E
|
||||
param y content bool
|
||||
param z content bool
|
||||
|
||||
new scope B:
|
||||
param x content E
|
||||
param y content bool
|
||||
param z content bool
|
||||
|
||||
scope A:
|
||||
def x := Case1 content 2
|
||||
def y := x with Case1
|
||||
def z := x with Case2
|
||||
|
||||
scope B:
|
||||
def x := Case2
|
||||
def y := x with Case3
|
||||
*/
|
15
tests/test_enum/quick_pattern_2.catala.A.out
Normal file
15
tests/test_enum/quick_pattern_2.catala.A.out
Normal file
@ -0,0 +1,15 @@
|
||||
[ERROR] Error during typechecking, types (any[49]) and (integer +
|
||||
[ERROR] unit) are incompatible
|
||||
[ERROR]
|
||||
[ERROR] Type (any[49]) coming from expression:
|
||||
[ERROR] --> test_enum/quick_pattern_2.catala
|
||||
[ERROR] |
|
||||
[ERROR] 28 | def y := x with Case3
|
||||
[ERROR] | ^
|
||||
[ERROR]
|
||||
[ERROR] Type (integer +
|
||||
[ERROR] unit) coming from expression:
|
||||
[ERROR] --> test_enum/quick_pattern_2.catala
|
||||
[ERROR] |
|
||||
[ERROR] 17 | param x content E
|
||||
[ERROR] | ^
|
19
tests/test_enum/quick_pattern_3.catala
Normal file
19
tests/test_enum/quick_pattern_3.catala
Normal file
@ -0,0 +1,19 @@
|
||||
@Article@
|
||||
|
||||
/*
|
||||
new enum E:
|
||||
-- Case1
|
||||
-- Case2
|
||||
|
||||
new enum F:
|
||||
-- Case3
|
||||
-- Case4
|
||||
|
||||
new scope A:
|
||||
param x content E
|
||||
param y content bool
|
||||
|
||||
scope A:
|
||||
def x := Case1
|
||||
def y := x with Case3
|
||||
*/
|
3
tests/test_enum/quick_pattern_3.catala.A.out
Normal file
3
tests/test_enum/quick_pattern_3.catala.A.out
Normal file
@ -0,0 +1,3 @@
|
||||
[RESULT] Computation successful! Results:
|
||||
[RESULT] x = Case1 ()
|
||||
[RESULT] y = true
|
18
tests/test_enum/quick_pattern_4.catala
Normal file
18
tests/test_enum/quick_pattern_4.catala
Normal file
@ -0,0 +1,18 @@
|
||||
@Test@
|
||||
|
||||
/*
|
||||
new enum E:
|
||||
-- Case1
|
||||
-- Case2
|
||||
|
||||
new enum F:
|
||||
-- Case3
|
||||
|
||||
new scope A:
|
||||
param x content E
|
||||
param y content bool
|
||||
|
||||
scope A:
|
||||
def x := Case1
|
||||
def y := x with Case3
|
||||
*/
|
15
tests/test_enum/quick_pattern_4.catala.A.out
Normal file
15
tests/test_enum/quick_pattern_4.catala.A.out
Normal file
@ -0,0 +1,15 @@
|
||||
[ERROR] Error during typechecking, types (any[10]) and (unit +
|
||||
[ERROR] unit) are incompatible
|
||||
[ERROR]
|
||||
[ERROR] Type (any[10]) coming from expression:
|
||||
[ERROR] --> test_enum/quick_pattern_4.catala
|
||||
[ERROR] |
|
||||
[ERROR] 17 | def y := x with Case3
|
||||
[ERROR] | ^
|
||||
[ERROR]
|
||||
[ERROR] Type (unit +
|
||||
[ERROR] unit) coming from expression:
|
||||
[ERROR] --> test_enum/quick_pattern_4.catala
|
||||
[ERROR] |
|
||||
[ERROR] 12 | param x content E
|
||||
[ERROR] | ^
|
Loading…
Reference in New Issue
Block a user