Skip to content

Commit b702e9d

Browse files
committed
Fix Product meet functions with mismatched domains
1 parent ab84e30 commit b702e9d

File tree

1 file changed

+40
-25
lines changed

1 file changed

+40
-25
lines changed

middle_end/flambda/types/structures/product.rec.ml

Lines changed: 40 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -72,33 +72,43 @@ module Make (Index : Product_intf.Index) = struct
7272
let all_right = ref true in
7373
let env_extension = ref (TEE.empty ()) in
7474
let components_by_index =
75-
Index.Map.union (fun _index ty1 ty2 ->
76-
match Type_grammar.meet env ty1 ty2 with
77-
| Ok (meet_result, env_extension') ->
78-
begin match TEE.meet env !env_extension env_extension' with
75+
Index.Map.merge (fun _index ty1_opt ty2_opt ->
76+
match ty1_opt, ty2_opt with
77+
| None, None -> assert false
78+
| Some ty1, None ->
79+
all_right := false;
80+
Some ty1
81+
| None, Some ty2 ->
82+
all_left := false;
83+
Some ty2
84+
| Some ty1, Some ty2 ->
85+
begin match Type_grammar.meet env ty1 ty2 with
86+
| Ok (meet_result, env_extension') ->
87+
begin match TEE.meet env !env_extension env_extension' with
88+
| Bottom ->
89+
any_bottom := true;
90+
Some (Type_grammar.bottom_like ty1)
91+
| Ok extension ->
92+
env_extension := extension;
93+
begin match meet_result with
94+
| Left_input ->
95+
all_right := false;
96+
Some ty1
97+
| Right_input ->
98+
all_left := false;
99+
Some ty2
100+
| Both_inputs ->
101+
Some ty1
102+
| New_result ty ->
103+
all_left := false;
104+
all_right := false;
105+
Some ty
106+
end
107+
end
79108
| Bottom ->
80109
any_bottom := true;
81110
Some (Type_grammar.bottom_like ty1)
82-
| Ok extension ->
83-
env_extension := extension;
84-
begin match meet_result with
85-
| Left_input ->
86-
all_right := false;
87-
Some ty1
88-
| Right_input ->
89-
all_left := false;
90-
Some ty2
91-
| Both_inputs ->
92-
Some ty1
93-
| New_result ty ->
94-
all_left := false;
95-
all_right := false;
96-
Some ty
97-
end
98-
end
99-
| Bottom ->
100-
any_bottom := true;
101-
Some (Type_grammar.bottom_like ty1))
111+
end)
102112
components_by_index1
103113
components_by_index2
104114
in
@@ -247,7 +257,12 @@ module Int_indexed = struct
247257
in
248258
match get_opt fields1, get_opt fields2 with
249259
| None, None -> assert false
250-
| Some t, None | None, Some t -> t
260+
| Some t, None ->
261+
all_right := false;
262+
t
263+
| None, Some t ->
264+
all_left := false;
265+
t
251266
| Some ty1, Some ty2 ->
252267
begin match Type_grammar.meet env ty1 ty2 with
253268
| Ok (meet_result, env_extension') ->

0 commit comments

Comments
 (0)