Skip to content

Function .name and Function.prototype.toString leak compiler internals (Made$4, __anon_class_8, [native code]) #9413

Closed

Description

@proggeramlug
function outer(){ function inner(){} return inner.name }   // node "inner"   perry ""
// two classes both named Made, in different scopes:          node "Made"    perry "Made$4"
new (class extends Error{})("m").constructor.name           // node ""       perry "__anon_class_8"
String(class Klass{})                 // node "class Klass {}"        perry "function Klass() { [native code] }"
String(({ m(){ return 1 } }).m)       // node "m() { return 1; }"     perry "function () { [native code] }"

Top-level names and NamedEvaluation are correct; nested declarations and duplicate names are not, and the mangled forms (Made$4, __anon_class_8) leak the compiler's disambiguation into user-visible strings.

71 constructor.name uses in the cc bundle. Libraries routinely dispatch on constructor.name, and Function.prototype.toString is used for source reflection — both get wrong answers here rather than approximations.

Found by a differential stress-test of claude-code under perry.

Activity

  1. proggeramlug commented on Sep 2, 2026

    @proggeramlug
    ContributorAuthor

    Fixed by PR #9465, landed via #9472: .name reports the source name (not the Made$N disambiguation key), toString() returns real class source text via the new class-side source registry, and inspect prints [class Name]. Fixtures test_class_name_and_source_9413.ts + .cts arm. Verified on main 0a1c137d90 with a fresh build: fixture byte-identical to node --experimental-strip-types (stdout, stderr, and exit code).
    Follow-ups filed: #9466 (the underlying ClassId aliasing is WRONG CODE, still live), #9468 (method source text, accessor names, .cts NamedEvaluation).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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