Skip to content

Commit ed36912

Browse files
committed
FIX
1 parent d1a3713 commit ed36912

File tree

1 file changed

+16
-6
lines changed

1 file changed

+16
-6
lines changed

compiler/lib-wasm/typing.ml

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,14 @@ let update_deps st { blocks; _ } =
117117
List.iter block.body ~f:(fun i ->
118118
match i with
119119
| Let (x, Block (_, lst, _, _)) -> Array.iter ~f:(fun y -> add_dep st x y) lst
120+
| Let (x, Prim (Extern ("%int_and" | "%int_or" | "%int_xor"), lst)) ->
121+
(* The return type of these primitives depend on the input type *)
122+
List.iter
123+
~f:(fun p ->
124+
match p with
125+
| Pc _ -> ()
126+
| Pv y -> add_dep st x y)
127+
lst
120128
| _ -> ()))
121129
blocks
122130

@@ -159,14 +167,16 @@ let prim_type ~approx prim args =
159167
Number (Int Unnormalized)
160168
| "%int_and" -> (
161169
match List.map ~f:(fun x -> arg_type ~approx x) args with
162-
| [ Number (Int Unnormalized); Number (Int Unnormalized) ] ->
163-
Number (Int Unnormalized)
164-
| _ -> Number (Int Normalized))
170+
| [ (Bot | Number (Int (Ref | Normalized))); _ ]
171+
| [ _; (Bot | Number (Int (Ref | Normalized))) ] -> Number (Int Normalized)
172+
| _ -> Number (Int Unnormalized))
165173
| "%int_or" | "%int_xor" -> (
174+
Format.eprintf "XOR %a@." Domain.print (arg_type ~approx (List.hd args));
166175
match List.map ~f:(fun x -> arg_type ~approx x) args with
167-
| [ Number (Int Unnormalized); _ ] | [ _; Number (Int Unnormalized) ] ->
168-
Number (Int Unnormalized)
169-
| _ -> Number (Int Normalized))
176+
| [ (Bot | Number (Int (Ref | Normalized)))
177+
; (Bot | Number (Int (Ref | Normalized)))
178+
] -> Number (Int Normalized)
179+
| _ -> Number (Int Unnormalized))
170180
| "%int_lsr"
171181
| "%int_asr"
172182
| "%int_div"

0 commit comments

Comments
 (0)