Skip to content

Built-in property descriptors & .name/.length conformance (Test262 verifyProperty) #3143

Description

@proggeramlug

Summary

Built-in functions/methods/constructors don't expose spec-correct own-property descriptors, which is the single biggest gate on Test262 conformance (built-ins/*). Test262's verifyProperty (used in thousands of cases, via harness/propertyHelper.js) checks the full descriptor of every built-in method/property: value, writable, enumerable, configurable, plus the method's own .name/.length. A case only passes when all facets match.

Partial progress already landed: PR #2554 made built-in prototype methods enumerable:false. This issue covers the remaining descriptor facets.

Concrete gaps (Perry vs Node --experimental-strip-types)

// 1. Built-in constructor .length (and .name on reified values)
Array.name      // Perry "Array" ✓ (folded, #2144)   — but:
Array.length    // Perry 0        ✗   Node 1
Object.length   // Perry 0        ✗   Node 1

// 2. .name / .length on a method read as a VALUE (not the #2144 syntactic fold)
var m = [].map;
m.name          // Perry: CRASHES "Cannot read properties of undefined (reading 'name')"   Node "map"
m.length        // Node 1
Array.prototype.map.name    // Node "map"   (works via #2144 only for the exact syntactic form)

// 3. writable / configurable ENFORCEMENT (verifyProperty actively tests these)
//    - writing to a non-writable builtin prop must no-op (sloppy) / throw (strict)
//    - delete of a configurable builtin prop must succeed and remove it
//    - Object.getOwnPropertyDescriptor(Array.prototype.map, "name")
//        Perry {value:"map", writable:TRUE,  enumerable:false, configurable:true}
//        Node  {value:"map", writable:FALSE, enumerable:false, configurable:true}

.name/.length on a built-in method must be { writable:false, enumerable:false, configurable:true }; on a built-in method object itself the proto-method is { writable:true, enumerable:false, configurable:true } (done in #2554).

Where the code lives (as of current main)

Recommended approach

Acceptance criteria

  • Array.length===1, Object.length===1, etc.; [].map.name==="map", [].map.length===1 (no crash).
  • Object.getOwnPropertyDescriptor(Array.prototype.map, "name") === {value:"map", writable:false, enumerable:false, configurable:true}.
  • verifyProperty(Array.prototype, "map", {writable:true, enumerable:false, configurable:true}) passes; same for representative String/Number/TypedArray methods.
  • No regression to user-object descriptors or the object get/set hot path (don't flip the global gate).
  • Measure with scripts/test262_subset.py --dir built-ins/Array built-ins/String built-ins/Number --max 300.

Refs: Test262 radar #799, Node+TS roadmap #793. Pattern PRs: #2554, #2060, #2144.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew capability or improvementparityCompatibility gap with Node.js, ECMAScript, or the supported ecosystem

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions