Skip to content

Method/accessor source text and object-literal accessor names: String(C.prototype.m) is [native code]; get-accessor .name is "" #9468

Description

@proggeramlug

Follow-ups to #9413 (PR #9465), which added the class-side source registry (Module::class_source_text). Three smaller identity gaps remain, grouped because they share the fix surface:

  1. String(C.prototype.m) returns function () { [native code] }; node returns the method source (m() { return 1; }). Class methods compile to perry_method_* symbols rather than closures with a registered source, so the runtime: Function.prototype.toString returns [object Object] for functions (no source reconstruction; no this brand check) #4101 closure source registry never sees them. Needs the method-side equivalent of what PR fix: static this is the constructor, not an instance (#9404); class .name/toString/inspect report source identity (#9413) #9465 built for classes — ast::ClassMethod spans sliced the same way. (Object-literal method toString already works — the PR's objmethod-toString control proves the registry is live for closures.)

  2. Object-literal accessor .name is "" where node gives "get g" / "set s". Class accessors are correct ("get p"), so the NamedEvaluation prefixing exists — the object-literal lowering path doesn't call it.

  3. .cts NamedEvaluation gaps, upstream of class metadata entirely: module.exports = class {} gets .name === "__perry_cjs_default__" from the pre-parse source rewrite (cjs_wrap/hoist_classes.rs:178; node: ""), and const C = class {} inside a .cts loses NamedEvaluation ("" vs "C"). The committed test_class_name_cjs_9413.cts documents both and deliberately does not assert them — un-skip those arms as part of this fix.

Verification bar

Extend the two #9413 fixtures rather than adding new ones: method/getter/setter/static-method source text through String(), .toString() and template interpolation; async and generator methods; object-literal get/set names; the two .cts arms un-skipped. All byte-compared to node, each demonstrated failing before the change.

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