Expand description
Bounds-checked array indexing.
arr[i] lowers to a raw array.get/array.set, which traps uncatchably on
an out-of-range index. A trap halts the program and can’t be intercepted by
user try/catch, turning a user-controlled index into a DoS vector. Instead
we range-check the index. A read that finds no element throws a catchable
MissingValueError (or gives undefined where the typechecker typed it
T | undefined), and a write outside the array throws RangeError,
matching how every other runtime fault surfaces (cast mismatch, etc.).
Functions§
- stash_
array_ length - Capture the logical length while leaving the array receiver on the stack.
- stash_
index_ operand - Stashes the
f64index sitting on the stack into a fresh local, ready for [emit_checked_index]. Kept separate from the check because a write must evaluate its RHS between the two — left-to-right evaluation order puts the RHS’s side effects before the check’s throw.