-
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
console.log("%s", { [Symbol.toPrimitive]: () => "hello" })
shows the object, not "hello"
#50909
Labels
Comments
According to the spec, this is a bug in node.js Spec: |
himself65
added
confirmed-bug
Issues with confirmed bugs.
console
Issues and PRs related to the console subsystem.
labels
Nov 25, 2023
Looking into it. |
I believe this is because node/lib/internal/util/inspect.js Lines 2197 to 2216 in 2f40652
|
Ch3nYuY
added a commit
to Ch3nYuY/node
that referenced
this issue
Mar 18, 2024
Ensure console.log("%s", obj) correctly invokes obj[Symbol.toPrimitive] for string conversion, fixing unexpected object display issue. Fixes: nodejs#50909
Ch3nYuY
added a commit
to Ch3nYuY/node
that referenced
this issue
Mar 18, 2024
Ensure console.log("%s", obj) correctly invokes obj[Symbol.toPrimitive] for string conversion, fixing unexpected object display issue. Fixes: nodejs#50909
aduh95
pushed a commit
to Ch3nYuY/node
that referenced
this issue
May 11, 2024
This commit ensures `console.log("%s", obj)` correctly invokes `obj[Symbol.toPrimitive]` for string conversion, fixing unexpected object display issue. Fixes: nodejs#50909
aduh95
pushed a commit
that referenced
this issue
May 12, 2024
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>
targos
pushed a commit
that referenced
this issue
May 12, 2024
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>
marco-ippolito
pushed a commit
that referenced
this issue
Jun 17, 2024
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>
marco-ippolito
pushed a commit
that referenced
this issue
Jun 17, 2024
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>
marco-ippolito
pushed a commit
that referenced
this issue
Jun 17, 2024
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>
eliphazbouye
pushed a commit
to eliphazbouye/node
that referenced
this issue
Jun 20, 2024
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>
bmeck
pushed a commit
to bmeck/node
that referenced
this issue
Jun 22, 2024
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>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
Version
v21.2.0
Platform
Linux PIG-2016 5.15.90.1-microsoft-standard-WSL2 #1 SMP Fri Jan 27 02:56:13 UTC 2023 x86_64 x86_64 x86_64 GNU/Linux
Subsystem
inspect
What steps will reproduce the bug?
How often does it reproduce? Is there a required condition?
always
What is the expected behavior? Why is that the expected behavior?
deno does:
chrome browser does:
bun does:
firefox browser does:
makes sense; it has a stringifier so it should act just like it would if it had a toString() which Node.js does recognize:
What do you see instead?
Additional information
No response
The text was updated successfully, but these errors were encountered: