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.
22 lines
903 B
JavaScript
22 lines
903 B
JavaScript
const out = []
|
|
const probe = (label, f) => {
|
|
const r = [label, f.hasOwnProperty("length"), f.hasOwnProperty("name")]
|
|
try { r.push(delete f.length) } catch (e) { r.push("E " + e.message) }
|
|
r.push(f.hasOwnProperty("length"), f.length)
|
|
try { r.push(delete f.name) } catch (e) { r.push("E " + e.message) }
|
|
r.push(f.hasOwnProperty("name"), JSON.stringify(f.name))
|
|
try { f.length = 9; r.push(f.length) } catch (e) { r.push("E " + e.message) }
|
|
r.push(Object.keys(f).join(","))
|
|
out.push(r.join(" | "))
|
|
}
|
|
probe("native", String.prototype.charAt)
|
|
probe("uri", encodeURI)
|
|
function g(a, b) {}
|
|
probe("closure", g)
|
|
probe("arrow", (a) => a)
|
|
probe("bound", g.bind(null, 1))
|
|
probe("ctor", Map)
|
|
function g3(a, b, c) {}
|
|
const b1 = g3.bind(null, 1), b2 = b1.bind(null, 2, 3, 4), b3 = Math.max.bind(null)
|
|
out.push(b1.length, b1.name, b2.length, b2.name, b3.length, b3.name, (() => 1).bind().name)
|
|
return out
|