Repository navigation
Function maps: Name private class methods and properties - #2328
Conversation
generateFunctionMap only took names from ClassMethod/ClassProperty keys, so
`#m() {}`, `static #s() {}`, `get #g() {}` and `#p = () => {}` were all
mapped to `<anonymous>`, and symbolicated stack traces lost the frame's name.
Treat ClassPrivateMethod/ClassPrivateProperty like their public counterparts
and name a PrivateName key `#name` (C##m, C.#s, C#get__#g).
Metro review: Looks goodRisk: low · Commit: The PR names private class methods, accessors and arrow-function properties in function maps ( No findings. Verified
Not run: No benchmark: the change only adds two type-guard checks per function node in generateFunctionMap, which won't measurably change cost. I didn't check function maps from hermes-parser ASTs, because hermes-parser isn't installed in the checkout. I didn't run anything on Windows because the logic is platform-neutral. Automated review by Claude. Advisory only: it never approves or blocks, and a maintainer makes the call. |
A callback passed to a call on a private member, this.#p.call(function () {}),
is now named #p.call$argument_0 where it used to be call$argument_0. Pin it.
|
Looks good, thanks! |
Summary
generateFunctionMapnames a class member's function from theClassMethod/ClassPropertykey, but not from private members.#m() {},static #s() {},get #g() {}and#p = () => {}all get<anonymous>in the function map, so a symbolicated stack trace loses the name of any frame inside a private method:This change treats
ClassPrivateMethodandClassPrivatePropertylike their public counterparts and names aPrivateNamekey#name, with the existing separators:Cart##total(instance),Wallet.#parse(static),C#get__#g(getter). The samePrivateNamehandling also names the callback afterthis.#items.reduce, soreduce$argument_0becomes#items.reduce$argument_0, asthis.items.reduce(...)already givesitems.reduce$argument_0.flowchart TD A[A crash inside a private class method] --> B{Function map entry for the method} B -->|Before| C[Anonymous frame in the symbolicated trace] B -->|After| D[Frame named Cart##total]Changelog: [Fix] Function maps name private class methods and properties instead of
<anonymous>Test plan
Added
class private methods and propertiestogenerateFunctionMap-test.js(instance, static, getter and arrow-property private members). It fails onmain(all four map to<anonymous>) and passes with this change:I did not run the full
yarn test. No exported types changed.End to end with the Metro CLI and
metro-symbolicatefrom this branch (React Native Babel transformer), usingcart.jsabove andindex.js:Narrated recording, before then after (sound on):
evidence.mp4
Edge cases and unchanged behaviour checked in the recording (the CLI from this branch):
#describe = () => this.balance.toFixed(2), is symbolicated asWallet##describestatic #parse(text), is symbolicated asWallet.#parseCart#checkout,Wallet.load), and the development build (--dev true) names the same framesAI assistance (Claude Code) was used to find this bug, write the change and run the checks above.
🤖 Generated with Claude Code