Files
scriptc/tests/corpus/2755-array-optional-literal-forwarding.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

11 lines
481 B
TypeScript

// Optional values carried through locals and function returns still occupy the UNDEFINED state.
const source: number[] = [12];
const missing = source[8];
function maybe(values: number[]): number {
return values[8];
}
const localLiteral = [missing, source[0]];
const returnedLiteral = [maybe(source), source[0]];
console.log("local", localLiteral.length, localLiteral[0], localLiteral[1]);
console.log("returned", returnedLiteral.length, returnedLiteral[0], returnedLiteral[1]);