Skip to content

bug: built-in prototype methods (Object/Number.prototype isPrototypeOf, hasOwnProperty, …) undefined as property values and via primitive receivers #2059

Closed

Description

@proggeramlug

Summary

A function's built-in name own-property reads back undefined, and Object.getOwnPropertyDescriptor(fn, "name") returns undefined. Per spec, name is a { writable:false, enumerable:false, configurable:true } own data property.

Repro

function foo(a, b) {}
console.log(foo.name);    // expect: "foo"   — Perry: undefined
console.log(foo.length);  // expect: 2       — Perry: 2 (ok)
console.log(Object.getOwnPropertyDescriptor(foo, "name"));
// expect: {value:"foo", writable:false, enumerable:false, configurable:true}
// Perry:  undefined
Node v25 Perry
foo.name "foo" undefined
getOwnPropertyDescriptor(foo,"name") accessor/data desc undefined
foo.length 2 2 ✓

Why it matters

built-ins/Function was ~20% in the #799 Test262 baseline, dominated (22× in the sample) by Cannot read properties of undefined (reading 'name'). It also breaks Test262's assert.throws, which reports thrown.constructor.name (assert.js:130-131) — degrading error reporting across all negative tests. And it breaks ordinary fn.name usage (router tables, DI containers, logging).

Likely cause

name (and likely other built-in own data properties) is not installed on function objects. Note length works, so the function-object property machinery exists — name specifically is not being populated from the declaration/binding identifier.

Related: #1802 (custom property on a function object reads back undefined) — adjacent, but this is the spec built-in name.

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