'index out of bound' check too early? #4892
Original bug ID: 4892
One expects arguments of a function call to be evaluated before the function is called. This is not the case in the following expression, using the native code compiler:
let () = Array.set [| |] 0 (print_endline "XXX")
The exception Invalid_argument("index out of bounds") is raised before the argument (print_endline "XXX") is evaluated.
The text was updated successfully, but these errors were encountered:
Comment author: ertai
Why do you expects the arguments of this function to be all evaluated before doing the update.
Array.set could morally be seen as:
let set array index =
Which have the nice property of checking once the bounds:
let isetter = Array.set array i in
However the reports is still worthy since the behavior should be the same in bytecode.