Mark the borrowed array read fallback as read-only (#2503)

This commit is contained in:
Chris Tate
2026-10-28 22:28:17 -05:00
committed by GitHub
@@ -682,7 +682,11 @@ export function emitBorrowedArrayRead(
B.startBlock(slow);
host.declare("declare ptr @scr_arr_borrow_ref(ptr, double)");
const value = B.tmp();
B.line(`${value} = call ptr @scr_arr_borrow_ref(ptr ${array.name}, double ${index.name})`);
// The fallback only reads the array (a hole or an out-of-range index
// traps), so loops keep the array's header loads hoisted past it.
B.line(
`${value} = call ptr @scr_arr_borrow_ref(ptr ${array.name}, double ${index.name})${READ_FALLBACK}`,
);
B.line(`store ptr ${value}, ptr ${slot}`);
B.br(join);
B.startBlock(join);