Files
scriptc/tests/library-mode/int-trap/lib.ts
Chris Tate 94fd361b54 Implement sparse native arrays and missing-value parity (#297)
Represent ordinary JavaScript arrays with hole, value, and explicit-undefined states; add sparse side storage and carry missing values through the frontend, native backends, runtime, and Node-facing consumers.
2026-09-12 22:39:07 -05:00

20 lines
621 B
TypeScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
/* Ask 4's inbound declared-integer edge: `take`'s parameter is
* profile-declared i64 (takeU's u64), so the generated wrapper
* range-checks every HOST call — a value past ±(2^53 − 1) cannot ride
* f64 exactly, and silent rounding is a coercion the author never wrote,
* so the wrapper delivers the SC4012 host-contract trap instead.
* In-range values convert exactly. */
let seen: number[] = [];
export function take(x: number): void {
seen.push(x);
}
export function takeU(x: number): void {
seen.push(x);
}
export function last(): number {
return seen.length === 0 ? -1 : seen[seen.length - 1]!;
}