mirror of
https://github.com/vercel-labs/scriptc.git
synced 2026-10-02 08:35:07 +08:00
- Preserve async factory results and mixed table layouts through inference and destructuring. - Support checked Map and Object.fromEntries construction with native weak collections. - Keep native weak-key lifetimes and engine-backed collection identities intact.
15 lines
614 B
JavaScript
15 lines
614 B
JavaScript
let calls = 0;
|
|
let x;
|
|
let y;
|
|
function make(value) { calls++; return value; }
|
|
const source = { nested: { make } };
|
|
const record = { x: 3, y: 7 };
|
|
const result = ({ x, y } = make(record));
|
|
console.log(calls, x, y, result === record);
|
|
({ x, y } = source.nested.make({ x: 11, y: 13 }));
|
|
console.log(calls, x, y);
|
|
try { ({ x } = make(null)); } catch (error) { console.log(error.name, error.message); }
|
|
try { ({ x } = source.nested.make(undefined)); } catch (error) { console.log(error.name, error.message); }
|
|
try { ({} = make(undefined)); } catch (error) { console.log(error.name, error.message); }
|
|
console.log(calls);
|