Files
scriptc/tests/corpus/2787-array-missing-string-arithmetic.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

24 lines
707 B
TypeScript

const words: string[] = [];
words[1] = "x";
const leftMissing = words[0] + 1;
const rightMissing = 1 + words[0];
const bothMissing = words[0] + words[2];
const present = words[1] + 1;
console.log("stored", typeof leftMissing, leftMissing, typeof rightMissing, rightMissing);
console.log("pairs", typeof bothMissing, bothMissing, typeof present, present);
function compute(index: number): string {
return words[index] + 1;
}
const missingCall = compute(4);
const presentCall = compute(1);
console.log("calls", typeof missingCall, missingCall, typeof presentCall, presentCall);
let calls = 0;
function next(): string[] {
calls++;
return words;
}
console.log("effects", next()[0] + next()[1], calls);