Join GitHub today
GitHub is home to over 36 million developers working together to host and review code, manage projects, and build software together.Sign up
'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.
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.