Skip to content

Commit 70d2af7

Browse files
committed
Fixed tags with recursive type definitions
1 parent eca06cf commit 70d2af7

1 file changed

Lines changed: 7 additions & 4 deletions

File tree

interpreter/valid/valid.ml

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,10 @@ let check_limits {min; max} range at msg =
125125
require (I64.le_u min max) at
126126
"size minimum must not be greater than maximum"
127127

128+
let check_def_type (c : context) (t : def_type) at =
129+
match t with
130+
| DefT (RecT sts, i) -> assert Int32.(compare i (of_int (List.length sts)) < 0)
131+
128132
let check_num_type (c : context) (t : num_type) at =
129133
()
130134

@@ -139,7 +143,8 @@ let check_heap_type (c : context) (t : heap_type) at =
139143
| ExnHT | NoExnHT
140144
| ExternHT | NoExternHT -> ()
141145
| VarHT (StatX x) -> let _dt = type_ c (x @@ at) in ()
142-
| VarHT (RecX _) | DefHT _ -> assert false
146+
| VarHT (RecX _) -> assert false
147+
| DefHT dt -> check_def_type c dt at
143148
| BotHT -> ()
144149

145150
let check_ref_type (c : context) (t : ref_type) at =
@@ -180,9 +185,7 @@ let check_func_type (c : context) (ft : func_type) at =
180185

181186
let check_cont_type (c : context) (ct : cont_type) at =
182187
match ct with
183-
| ContT (VarHT (StatX x)) ->
184-
let _dt = func_type c (x @@ at) in ()
185-
| _ -> assert false
188+
| ContT ht -> let _dt = func_type_of_heap_type c ht at in ()
186189

187190
let check_table_type (c : context) (tt : table_type) at =
188191
let TableT (at_, lim, t) = tt in

0 commit comments

Comments
 (0)