Skip to content

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

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

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