util: treat format arguments equally, add format string detection#23162
util: treat format arguments equally, add format string detection#23162silverwind wants to merge 2 commits into
Conversation
912095b to
3e9593c
Compare
|
Should we update this note with something like this:
|
|
@vsemozhetbyt thanks, updated docs quite a bit to be more accurate and also renamed |
|
I think it's an edge case, but still needs to be treated as semver major just to be safe. Our own test suite has not been a great measuring stick in the past for these things. If others feel strongly that it's not semver major, feel free to remove the label. |
|
On second thought, I'm fine with keeping it major. |
|
From citgm, something changes independently of the first string parameter content: |
|
Another one: That may be because I use |
|
Looks like the old implementation did use Guess I have to reimplement this inconsistency for the sake of compatibilty. |
|
I cannot fix above errors without re-introducing the issue that this was meant to fix. Our current implementation of My implementation removes this inconsistency by always formatting arguments the same, regardless of their position in the argument list: I think this is the best compromise we can do and it's worth the breaking change in the console output. A even better way could be to run all types through |
4ca4637 to
5e6c70d
Compare
|
Added a second changelog entry to clarify the details on the formatting change. If we disregard color, the only real difference in console/format output is on the arguments |
|
Looks like this needs a rebase? :/ |
There was a problem hiding this comment.
Maybe move this to the next paragraph, that explains what happens to those.
There was a problem hiding this comment.
Yeah makes sense, I moved it after the code block.
Two changes here which bring us closer to the console standard: - Arguments to `util.format` are no longer formatted differently depending on their order, with format strings being an exception. - Format specifier formatting is now only triggered if the string actually contains a format string. Under the hood, we now use a single shared function to format the given arguments which will make the code easier to read and modify. PR-URL: nodejs#23162 Fixes: nodejs#23137
d26abf5 to
9e5ccb0
Compare
|
Rebased and addressed @refack's comment on docs. Also, new commit message. |
|
Thanks, Landed in c1b9be5. |


Checklist
make -j4 test(UNIX), orvcbuild test(Windows) passesPreviously, a string first argument was treated as a format string even if it did not actually contain format specifiers. Now it will only be treated as a format string when it contains format specifiers which is in line with the Console Standard.
Additionally, this eliminates output inconsistencies in the non-format-string case where elements were output differently depending on their position in the argument list.