Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions interpreter/valid/valid.ml
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,10 @@ let check_limits {min; max} range at msg =
require (I64.le_u min max) at
"size minimum must not be greater than maximum"

let check_def_type (c : context) (t : def_type) at =
match t with
| DefT (RecT sts, i) -> assert Int32.(compare i (of_int (List.length sts)) < 0)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
| DefT (RecT sts, i) -> assert Int32.(compare i (of_int (List.length sts)) < 0)
| DefT (RecT sts, i) -> assert (i < Lib.List32.length sts)

But this isn't actually checking anything (only asserting), it seems to be redundant, and you could just do nothing at the call site?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did not know about Lib.List32, that is useful. I have fixed this.

I asserted the condition, since I am pretty sure an error at this location is an internal error and not an error the end-user can fix. I tried to think of an error message to provide to the user, but I did not find a good error message. What would you propose? (I could also remove the assert and do nothing; I would still prefer to keep the function call, much like eg. check_num_type).


let check_num_type (c : context) (t : num_type) at =
()

Expand All @@ -139,7 +143,8 @@ let check_heap_type (c : context) (t : heap_type) at =
| ExnHT | NoExnHT
| ExternHT | NoExternHT -> ()
| VarHT (StatX x) -> let _dt = type_ c (x @@ at) in ()
| VarHT (RecX _) | DefHT _ -> assert false
| VarHT (RecX _) -> assert false
| DefHT dt -> check_def_type c dt at
Comment thread
rajdakin marked this conversation as resolved.
Outdated
| BotHT -> ()

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

let check_cont_type (c : context) (ct : cont_type) at =
match ct with
| ContT (VarHT (StatX x)) ->
let _dt = func_type c (x @@ at) in ()
| _ -> assert false
| ContT ht -> let _dt = func_type_of_heap_type c ht at in ()

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