Skip to content

Add registered symbol cases to method and accessor name tests - #5140

Open
hexbinoct wants to merge 1 commit into
tc39:mainfrom
hexbinoct:registered-symbol-method-names
Open

hexbinoct wants to merge 1 commit into
tc39:mainfrom
hexbinoct:registered-symbol-method-names

Conversation

@hexbinoct

Copy link
Copy Markdown
Contributor

Closes #3436.

The method and accessor fn-name tests check .name for methods keyed by a unique symbol (Symbol('test262') gives [test262]) and by an anonymous one (the empty string), but never by a registered symbol from Symbol.for. SetFunctionName treats both kinds the same way: a Symbol key becomes its [[Description]] in brackets, and Symbol.for stores its key string as the description. XS got this wrong for registered symbols and returned the description without brackets (Moddable-OpenSource/moddable#876), which is where this issue came from.

This adds a Symbol.for('registered') key next to the existing unique-symbol key in the eight tests that cover methods and accessors:

  • object literal methods and generator methods
  • class methods and generator methods, prototype and static
  • object literal and class getters and setters, prototype and static

Each gets the same verifyProperty check as its unique-symbol neighbour, expecting [registered] (or get [registered] / set [registered]).

I left the fn-name-arrow, -class, -cover, -fn and -gen tests for property assignments like { [sym]: function () {} } alone, since those reach SetFunctionName through NamedEvaluation, not DefineMethod, and the issue is about methods. Happy to extend them too if that is wanted.

Checked locally with Node and engine262: all eight pass, and each one fails on both when its expected value is changed to the XS output (registered without brackets). Thanks to gibson042 for the report and the XS repro.

LLM disclosure: Claude Opus 5.5 helped me find the gap, write the change and check it; I reviewed the result.

SetFunctionName wraps a Symbol key's description in brackets, and a registered symbol's description is its key string, so a method keyed by Symbol.for('registered') is named '[registered]'. The existing tests only used unique symbols, which is how XS shipped a bug that dropped the brackets for registered ones.
@hexbinoct
hexbinoct requested a review from a team as a code owner September 24, 2026 10:41
@github-actions

Copy link
Copy Markdown

8 new or modified tests were run on 7 engines.

View workflow run

Test Engine262 GraalJS JavaScriptCore QuickJS SpiderMonkey V8 XS
language/expressions/object/fn-name-accessor-get.js ✅ ✅ ✅ ✅ ✅ ✅ ✅
language/expressions/object/fn-name-accessor-set.js ✅ ✅ ✅ ✅ ✅ ✅ ✅
language/expressions/object/method-definition/fn-name-fn.js ✅ ✅ ✅ ✅ ✅ ✅ ✅
language/expressions/object/method-definition/fn-name-gen.js ✅ ✅ ✅ ✅ ✅ ✅ ✅
language/statements/class/definition/fn-name-accessor-get.js ✅ ✅ ✅ ✅ ✅ ✅ ✅
language/statements/class/definition/fn-name-accessor-set.js ✅ ✅ ✅ ✅ ✅ ✅ ✅
language/statements/class/definition/fn-name-gen-method.js ✅ ✅ ✅ ✅ ✅ ✅ ✅
language/statements/class/definition/fn-name-method.js ✅ ✅ ✅ ✅ ✅ ✅ ✅

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Missing tests for registered symbol as method property key

1 participant