mirror of
https://github.com/vercel-labs/scriptc.git
synced 2026-10-16 05:00:59 +08:00
- Evolving-any receivers holding checked-dynamic values take keyed writes with ToPropertyKey-exact key spelling; dyn-keyed reads gain the same key stringification - Array destructuring over dyn sources packs via the spread walk with V8's exact non-iterable TypeError wordings - The dyn keyed-write miss error appends the primitive's rendering, matching Node # Conflicts: # packages/compiler/src/frontend/lowering/lower-exprs.ts # packages/compiler/src/ir/validate.ts
52 lines
1.5 KiB
JavaScript
52 lines
1.5 KiB
JavaScript
// Array destructuring over checked-dynamic sources (dyn.iterPack): decl,
|
|
// assignment, and callback-param forms; holes, past-the-end undefined,
|
|
// defaults firing exactly on undefined (null passes through), nested
|
|
// patterns, string sources by code point — and V8's destructuring
|
|
// TypeError wordings: the identifier spelling for named sources, the
|
|
// kind wording ("number 5 is not iterable (cannot read property
|
|
// Symbol(Symbol.iterator))") for parameters and expressions.
|
|
'use strict';
|
|
const rows = JSON.parse('[["m1","c1"],["m2","c2"]]');
|
|
rows.forEach(([msg, code]) => console.log('fe', msg, code));
|
|
const first = rows[0];
|
|
const [m, c] = first;
|
|
console.log('decl', m, c);
|
|
const [, tail] = rows[1];
|
|
console.log('hole', tail);
|
|
const [a, b] = JSON.parse('["only"]');
|
|
console.log('past', a, b);
|
|
const [d = 'dflt'] = JSON.parse('[]');
|
|
console.log('default', d);
|
|
const [n = 'dflt'] = JSON.parse('[null]');
|
|
console.log('null-through', n);
|
|
const [[x, y]] = JSON.parse('[[1,2]]');
|
|
console.log('nested', x, y);
|
|
const [c1, c2] = JSON.parse('"hé"');
|
|
console.log('str', c1, c2);
|
|
let p, q;
|
|
[p, q] = rows[1];
|
|
console.log('assign', p, q);
|
|
const bad = JSON.parse('5');
|
|
try {
|
|
const [z] = bad;
|
|
} catch (err) {
|
|
console.log('caught:', err.message);
|
|
}
|
|
try {
|
|
const [z] = JSON.parse('{"a":1}');
|
|
} catch (err) {
|
|
console.log('caught:', err.message);
|
|
}
|
|
const g = ([z]) => z;
|
|
try {
|
|
g(JSON.parse('null'));
|
|
} catch (err) {
|
|
console.log('caught:', err.message);
|
|
}
|
|
try {
|
|
g(JSON.parse('true'));
|
|
} catch (err) {
|
|
console.log('caught:', err.message);
|
|
}
|
|
console.log('done');
|