Description
Version
v18.5.0
Platform
n/a
Subsystem
No response
What steps will reproduce the bug?
node -pe 'RegExp.$_'
will print out WeakRef
.
node
, and then RegExp.$_
, will print out '\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'
.
This also applies to $&
.
How often does it reproduce? Is there a required condition?
No response
What is the expected behavior?
No response
What do you see instead?
I expect the empty string for all RegExp statics.
This is a problem for a few reasons:
- it exposes internal regular expression usage in node core
- the value might change from any version to any version, so if anyone's foolish enough to rely on it, they'll break in a non-major
- it's unseemly
If there's a point, right before node starts running user code, and right before the repl becomes available, then we could execute a trivial regular expression operation to clear all the statics.
Alternatively, this may be exposing non-primordial regex usage, and it's likely that switching to primordials (since I believe they'd update the statics on the primordial RegExp instead of the global RegExp) would solve this as well.
Additional information
No response