Skip to content

bug: built-in function .name own-property returns undefined (function foo(){}; foo.name === undefined) #2060

Description

@proggeramlug

Summary

Accessor (getter/setter) properties on built-in prototypes are not reflectable: Object.getOwnPropertyDescriptor(%TypedArray%.prototype, "length") returns undefined, where the spec defines length, byteLength, byteOffset, and buffer as accessor properties with a get. User-defined accessors round-trip correctly, so the descriptor machinery works — built-in accessors just aren't modeled as real accessor properties.

Repro

var TAp = Object.getPrototypeOf(Int8Array.prototype);   // %TypedArray%.prototype
var d = Object.getOwnPropertyDescriptor(TAp, "length");
console.log(d && Object.keys(d).sort().join(","), "| get:", d && typeof d.get);
// Node:  "configurable,enumerable,get,set" | get: function
// Perry: "(undefined desc)"                | get: undefined

// (control) user-defined accessor works in BOTH:
var o = {}; Object.defineProperty(o, "p", { get(){ return 42; }, configurable:true, enumerable:true });
console.log(o.p, Object.getOwnPropertyDescriptor(o, "p").get && "has-get"); // 42 has-get  (both)

Why it matters

This is the Cannot read properties of undefined (reading 'get') cascade (16× in the built-ins/TypedArray sample) and contributes to TypedArray being ~1% in the #799 baseline. Any test that introspects a built-in getter via getOwnPropertyDescriptor(...).get fails.

Likely cause

length/byteLength/etc. on TypedArray (and presumably other built-in getters) are computed via codegen special-cases rather than installed as real accessor properties on the prototype, so reflection can't see them. Same root theme as the Function.prototype.call / builtin-prototype-method gaps: built-in members aren't reified as real properties.

Surfaced by the #799 Test262 radar. Part of #793.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions