-
Notifications
You must be signed in to change notification settings - Fork 30k
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
inspect: fix console.log(%s, { [Symbol.toPrimitive]: () => hello }) #50992
Conversation
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.
The former implementation had it's reason as well as the internal toString method is mostly not ideal. The main problem is that hasBuiltInToString
does not know about the toPrimitive symbol. By checking for that, it would handle both cases right.
Thank you. Are you suggesting to modify it this way?
|
@chenyuyang2022 no, the |
baf1b8c
to
79df127
Compare
@BridgeAR Thank you for the reminder. I have modified the implementation and passed all the tests with 'make test'. |
@legendecas PTAL |
Would you mind updating the |
@legendecas Thank you, I've made the changes according to your suggestions. Could you please take a look? |
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
@BridgeAR would you mind taking a look again? |
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.
Thanks for following up upon this!
LGTM with the comment removed.
@BridgeAR Would you mind reviewing it again? |
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
We have to change the commit message when merging. It should be e.g., util: fix %s format for objects with Symbol.toPrimitive
.
@Ch3nYuY thank you for following up on the comments! |
@Ch3nYuY seems like there is a linter error that has to be resolved before it's possible to land this |
Thank you, @BridgeAR . I'll see how to solve it |
@BridgeAR I've solved all the linter error. Could you please add the 'request-ci' tag again? |
Hey @Ch3nYuY, the recent commits block the PR from being merged. Can you please rebase? :) |
Thanks! @BridgeAR I resolved the merge conflicts and it should look ok now. |
This commit ensures `console.log("%s", obj)` correctly invokes `obj[Symbol.toPrimitive]` for string conversion, fixing unexpected object display issue. Fixes: nodejs#50909
This commit ensures `console.log("%s", obj)` correctly invokes `obj[Symbol.toPrimitive]` for string conversion, fixing unexpected object display issue. PR-URL: #50992 Fixes: #50909 Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Chengzhong Wu <legendecas@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Zeyu "Alex" Yang <himself65@outlook.com>
This commit ensures `console.log("%s", obj)` correctly invokes `obj[Symbol.toPrimitive]` for string conversion, fixing unexpected object display issue. PR-URL: #50992 Fixes: #50909 Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Chengzhong Wu <legendecas@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Zeyu "Alex" Yang <himself65@outlook.com>
This commit ensures `console.log("%s", obj)` correctly invokes `obj[Symbol.toPrimitive]` for string conversion, fixing unexpected object display issue. PR-URL: #50992 Fixes: #50909 Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Chengzhong Wu <legendecas@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Zeyu "Alex" Yang <himself65@outlook.com>
This commit ensures `console.log("%s", obj)` correctly invokes `obj[Symbol.toPrimitive]` for string conversion, fixing unexpected object display issue. PR-URL: #50992 Fixes: #50909 Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Chengzhong Wu <legendecas@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Zeyu "Alex" Yang <himself65@outlook.com>
This commit ensures `console.log("%s", obj)` correctly invokes `obj[Symbol.toPrimitive]` for string conversion, fixing unexpected object display issue. PR-URL: #50992 Fixes: #50909 Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Chengzhong Wu <legendecas@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Zeyu "Alex" Yang <himself65@outlook.com>
This commit ensures `console.log("%s", obj)` correctly invokes `obj[Symbol.toPrimitive]` for string conversion, fixing unexpected object display issue. PR-URL: nodejs#50992 Fixes: nodejs#50909 Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Chengzhong Wu <legendecas@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Zeyu "Alex" Yang <himself65@outlook.com>
This commit ensures `console.log("%s", obj)` correctly invokes `obj[Symbol.toPrimitive]` for string conversion, fixing unexpected object display issue. PR-URL: nodejs#50992 Fixes: nodejs#50909 Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Chengzhong Wu <legendecas@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Zeyu "Alex" Yang <himself65@outlook.com>
console.log("%s", o)
invokes theinspect
method to retrieve the object. This results inconsole.log("%s", { [Symbol.toPrimitive]: () => "hello" })
displaying the object itself, rather than 'hello'.Fixes: #50909