mirror of
https://github.com/anomalyco/opencode.git
synced 2026-11-29 11:42:17 +00:00
A function's own name and length are configurable in the reference:
deleting one leaves the inherited Function.prototype value ("" and 0), and
assigning still fails as read-only. Two object flags record the deletion,
and reads, 'in' and hasOwnProperty honour them; a frozen or sealed
function still refuses. bind now gives the bound function its own
'bound <name>' and the target's length less the bound arguments.
delete's errors read 'Cannot delete property 'k'.' everywhere, as in the
reference, for arrays and Uint8Array too. Touches object.rs (flags) and
ops.rs (get, has, has_own, delete).
25 test262 files leave rust-skipped.txt.
16 lines
950 B
JavaScript
16 lines
950 B
JavaScript
const out = []
|
|
function f(a) {}
|
|
Object.freeze(f)
|
|
try { out.push(delete f.length) } catch (e) { out.push(e.message) }
|
|
const s = function named(b) {}
|
|
Object.seal(s)
|
|
try { out.push(delete s.name) } catch (e) { out.push(e.message) }
|
|
function g() {}
|
|
delete g.name
|
|
console.log(g, [g], { g })
|
|
const b = g.bind(null)
|
|
try { out.push(delete b.name, b.name, b.hasOwnProperty("name")) } catch (e) { out.push(e.message) }
|
|
out.push("length" in g, delete g.length, "length" in g, Object.isFrozen(f))
|
|
const o2 = Object.freeze({ a: 1 }); try { delete o2.a } catch (e) { out.push(e.message) }; const a2 = Object.seal([1]); try { delete a2[0] } catch (e) { out.push(e.message) }; try { delete [].length } catch (e) { out.push(e.message) };
|
|
const u = new Uint8Array(2); try { delete u[0] } catch (e) { out.push(e.message) }; try { out.push(delete u[5]) } catch (e) { out.push(e.message) }; try { out.push(delete u.length) } catch (e) { out.push(e.message) }
|
|
return out
|