-
Notifications
You must be signed in to change notification settings - Fork 29.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
util: add prototype support for boxed primitives #27351
util: add prototype support for boxed primitives #27351
Conversation
This comment has been minimized.
This comment has been minimized.
@nodejs/util PTAL |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This makes sure manipulated prototypes from boxed primitives will be highlighted. It also makes sure that a potential `Symbol.toStringTag` is taken into account.
2d7d167
to
21656b1
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
This comment has been minimized.
This comment has been minimized.
{ value: 'Foobar' } | ||
) | ||
), | ||
'[Number (Array): -0] [Foobar]' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👆 😮
let base = `[${type}`; | ||
if (type !== constructor) { | ||
if (constructor === null) { | ||
base += ' (null prototype)'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: Not a blocking comment.. But my thoughts..For objects, null prototype is showed as [Object: null prototype] {}
, looks like for primitives, we show as [Boolean (null prototype): true]
(like in test), may be we can show like [Boolean: null prototype] true
, so that reading is consistent.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought about that as well but I think it would be less obvious that it's a boxed primitive in that case (obviously, e.g., 5
is a number, so it might also just stand for extra information?).
The inconsistency is not ideal but this is likely going to be a super rare case anyway.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
This makes sure manipulated prototypes from boxed primitives will be highlighted. It also makes sure that a potential `Symbol.toStringTag` is taken into account. PR-URL: nodejs#27351 Reviewed-By: Matteo Collina <[email protected]> Reviewed-By: John-David Dalton <[email protected]> Reviewed-By: Anto Aravinth <[email protected]>
Landed in 55147d7. |
This makes sure manipulated prototypes from boxed primitives will be highlighted. It also makes sure that a potential `Symbol.toStringTag` is taken into account. PR-URL: #27351 Reviewed-By: Matteo Collina <[email protected]> Reviewed-By: John-David Dalton <[email protected]> Reviewed-By: Anto Aravinth <[email protected]>
This makes sure manipulated prototypes from boxed primitives will
be highlighted. It also makes sure that a potential
Symbol.toStringTag
is taken into account.
Checklist
make -j4 test
(UNIX), orvcbuild test
(Windows) passes