Skip to content

Commit dbaaffa

Browse files
committed
FIX
1 parent d1a3713 commit dbaaffa

File tree

1 file changed

+15
-6
lines changed

1 file changed

+15
-6
lines changed

compiler/lib-wasm/typing.ml

Lines changed: 15 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,15 @@ 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" -> (
166174
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))
175+
| [ (Bot | Number (Int (Ref | Normalized)))
176+
; (Bot | Number (Int (Ref | Normalized)))
177+
] -> Number (Int Normalized)
178+
| _ -> Number (Int Unnormalized))
170179
| "%int_lsr"
171180
| "%int_asr"
172181
| "%int_div"

0 commit comments

Comments
 (0)