bun
bun copied to clipboard
fix: distinguish getters and setters in Bun.inspect()
What does this PR do?
Fixes #8853.
This changes Bun.inspect to print "[Getter]", "[Setter]", or "[Getter/Setter]" for property accessors rather than always defaulting to "[Getter]".
To do so, we need to access the GetterSetter and CustomGetterSetter structures from zig, which requires expanding the bindings somewhat.
I've chosen to duplicate the code paths for GetterSetter and CustomGetterSetter to make it easier for future PRs to change them so we actually obtain references and print the getters and setters, which we can only do in the GetterSetter case.
Finally, two new tests ensure things work, though I'm not sure how to test the CustomGetterSetter case.
- [ ] Documentation or TypeScript types (it's okay to leave the rest blank in this case)
- [x] Code changes
How did you verify your code works?
I wrote automated tests.
- [x] I checked the lifetime of memory allocated to verify it's (1) freed and (2) only freed when it should be
- [x] I included a test for the new code, or an existing test covers it
- [x] JSValue used outside outside of the stack is either wrapped in a JSC.Strong or is JSValueProtect'ed
- [x] I wrote TypeScript/JavaScript tests and they pass locally (
bun-debug test test-file-name.test
)