Skip to content

Commit bd83c41

Browse files
committed
Type analysis: see through option types
Type `Tuple` stands for both integers and blocks. It describe the type of each field of the value when it is a block. This way, we can get a meaningful type when accessing the field of an option value, rather than just `Top`.
1 parent 2aa3cc2 commit bd83c41

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

compiler/lib-wasm/typing.ml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@ type typ =
2828
| Int of Integer.kind
2929
| Number of boxed_number
3030
| Tuple of typ array
31+
(** This value is a block or an integer; if it's an integer, an
32+
overapproximation of the possible values of each of its
33+
fields is given by the array of types *)
3134
| Bot
3235

3336
module Domain = struct
@@ -47,6 +50,8 @@ module Domain = struct
4750
else
4851
Array.init (max l l') ~f:(fun i ->
4952
if i < l then if i < l' then join t.(i) t'.(i) else t.(i) else t'.(i)))
53+
| Int _, Tuple _ -> t'
54+
| Tuple _, Int _ -> t
5055
| Top, _ | _, Top -> Top
5156
| (Int _ | Number _ | Tuple _), _ -> Top
5257

0 commit comments

Comments
 (0)