Skip to content
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: discrepancy in format() docs vs behavior #935

Closed
cjihrig opened this issue Feb 24, 2015 · 3 comments
Closed

util: discrepancy in format() docs vs behavior #935

cjihrig opened this issue Feb 24, 2015 · 3 comments
Labels
doc Issues and PRs related to the documentations.

Comments

@cjihrig
Copy link
Contributor

cjihrig commented Feb 24, 2015

There is a discrepancy between how the docs say util.format() works, and what really happens. The docs state:

If there are more arguments than placeholders, the extra arguments are converted to strings with util.inspect() and these strings are concatenated, delimited by a space.

However, only objects and symbols actually use util.inspect(). The required change is trivial, and I think we should bring behavior into line with what the docs say, but this is a slightly breaking change (there is at least one test that fails).

Originally reported in #931

@bnoordhuis
Copy link
Member

Is the issue that primitives are ToString'd? I think the output of util.inspect() is the same except in the case of strings, util.format() wraps them in quotes.

That would make for a mildly annoying change: console.log(util.format('and then:', 'nothing')) would start printing and then: 'nothing' instead of and then: nothing. I would move to just update the documentation.

@cjihrig
Copy link
Contributor Author

cjihrig commented Feb 24, 2015

Yep, that's the problem. A doc change sounds appropriate.

@cjihrig cjihrig added the doc Issues and PRs related to the documentations. label Feb 24, 2015
brendanashworth added a commit to brendanashworth/io.js that referenced this issue Mar 25, 2015
Only objects and symbols use `util.inspect`, others are simply
concatenated.

Fixes: nodejs#935
brendanashworth added a commit that referenced this issue Mar 25, 2015
Only objects and symbols use `util.inspect`, others are simply
concatenated.

Fixes: #935
PR-URL: #1255
Reviewed-By: Colin Ihrig <[email protected]>
@brendanashworth
Copy link
Contributor

Closed as fixed in 4581421.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
doc Issues and PRs related to the documentations.
Projects
None yet
Development

No branches or pull requests

3 participants