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: inspect: enumerable Symbols no longer have square brackets #55778

Closed
wants to merge 2 commits into from

Conversation

ljharb
Copy link
Member

@ljharb ljharb commented Nov 8, 2024

The intention of this change is to increase consistency. Before this PR, non-enumerable string properties have square brackets, and all Symbol properties have square brackets - meaning that without color cues, there's no way to determine whether a Symbol is enumerable or not, and it can be confusing whether [foo] is indeed bracketed because it's non-enumerable.

Due to the following considerations:

  1. minimizing disruption/changes to output
  2. square brackets are already used for a number of "special" things, including a data proto property, Symbol.toStringTag values, null objects, etc, so we already wouldn't be able to have square brackets mean only "computed properties"

… we decided to go with "enumerable Symbols do not have square brackets", so that all non-enumerables use square brackets.

Implements https://github.com/orgs/nodejs/discussions/41283#discussioncomment-11188239

@nodejs-github-bot nodejs-github-bot added needs-ci PRs that need a full CI run. util Issues and PRs related to the built-in util module. labels Nov 8, 2024
@ljharb
Copy link
Member Author

ljharb commented Nov 8, 2024

cc @BridgeAR

@avivkeller
Copy link
Member

avivkeller commented Nov 8, 2024

IMO this is a semver-major breaking change, as it breaks the existing behavior of brackets existing on all symbols

Copy link
Member

@BridgeAR BridgeAR left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Generally LGTM. Please also add a few tests for the now escaped non-enumerable key names that need escaping.

I am fine to consider it as semver-major, while we normally do not handle these changes as being part of semver. The output changes from time to time and it is considered a debugging utility that does not have a stable output. I suggest to just add a few do not land labels for now and consider it a semver minor change? It could theoretically be back parted at a later point that way.

lib/internal/util/inspect.js Outdated Show resolved Hide resolved
@avivkeller avivkeller added the semver-major PRs that contain breaking changes and should be released in the next major version. label Nov 8, 2024
@BridgeAR
Copy link
Member

BridgeAR commented Nov 8, 2024

@ljharb I would probably just take the gist out of the discussion and use that as commit description. That way it's clear that this is done for consistency reasons to distinguish non-enumerable properties easier.

@avivkeller
Copy link
Member

@BridgeAR I've added semver-major PRs that contain breaking changes and should be released in the next major version. for now, but if something changes, we can always adjust it to your suggestion.

@targos targos added dont-land-on-v18.x PRs that should not land on the v18.x-staging branch and should not be released in v18.x. dont-land-on-v20.x PRs that should not land on the v20.x-staging branch and should not be released in v20.x. dont-land-on-v22.x PRs that should not land on the v22.x-staging branch and should not be released in v22.x. dont-land-on-v23.x PRs that should not land on the v23.x-staging branch and should not be released in v23.x. and removed semver-major PRs that contain breaking changes and should be released in the next major version. labels Nov 8, 2024
Copy link

codecov bot commented Nov 8, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 88.40%. Comparing base (58a8eb4) to head (577b7e7).
Report is 3 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #55778      +/-   ##
==========================================
- Coverage   88.40%   88.40%   -0.01%     
==========================================
  Files         654      654              
  Lines      187815   187810       -5     
  Branches    36136    36140       +4     
==========================================
- Hits       166045   166035      -10     
- Misses      15001    15014      +13     
+ Partials     6769     6761       -8     
Files with missing lines Coverage Δ
lib/internal/util/inspect.js 99.95% <100.00%> (-0.05%) ⬇️

... and 37 files with indirect coverage changes

@ljharb ljharb force-pushed the nonenums branch 2 times, most recently from 8a7eda3 to 02d01fb Compare November 8, 2024 13:54
@ljharb ljharb force-pushed the nonenums branch 5 times, most recently from 577b7e7 to f4a5af6 Compare November 10, 2024 20:21
@ljharb

This comment was marked as resolved.

@RafaelGSS RafaelGSS added the request-ci Add this label to start a Jenkins CI on a PR. label Nov 11, 2024
@github-actions github-actions bot removed the request-ci Add this label to start a Jenkins CI on a PR. label Nov 11, 2024
@nodejs-github-bot
Copy link
Collaborator

@marco-ippolito marco-ippolito added the request-ci Add this label to start a Jenkins CI on a PR. label Nov 12, 2024
@github-actions github-actions bot removed the request-ci Add this label to start a Jenkins CI on a PR. label Nov 12, 2024
@nodejs-github-bot
Copy link
Collaborator

@ljharb
Copy link
Member Author

ljharb commented Nov 12, 2024

Of the 2 failures, both appear to be unrelated to the PR, and seem to be issues with git itself. Can someone take a look?

@nodejs-github-bot
Copy link
Collaborator

CI: https://ci.nodejs.org/job/node-test-pull-request/63531/

@marco-ippolito marco-ippolito added the author ready PRs that have at least one approval, no pending requests for changes, and a CI started. label Nov 13, 2024
@ljharb
Copy link
Member Author

ljharb commented Nov 14, 2024

CI doesn't seem to be running, despite someone resuming it multiple times. Can someone look into it?

@RafaelGSS
Copy link
Member

It seems nodejs/build#3959

@nodejs-github-bot
Copy link
Collaborator

CI: https://ci.nodejs.org/job/node-test-pull-request/63546/

@nodejs-github-bot
Copy link
Collaborator

CI: https://ci.nodejs.org/job/node-test-pull-request/63556/

@nodejs-github-bot
Copy link
Collaborator

CI: https://ci.nodejs.org/job/node-test-pull-request/63557/

@nodejs-github-bot
Copy link
Collaborator

@nodejs-github-bot
Copy link
Collaborator

@ljharb
Copy link
Member Author

ljharb commented Nov 17, 2024

yay, all green!

@atlowChemi atlowChemi added commit-queue Add this label to land a pull request using GitHub Actions. commit-queue-rebase Add this label to allow the Commit Queue to land a PR in several commits. labels Nov 17, 2024
@nodejs-github-bot nodejs-github-bot removed the commit-queue Add this label to land a pull request using GitHub Actions. label Nov 17, 2024
@nodejs-github-bot
Copy link
Collaborator

Landed in 9f2885a...e577618

nodejs-github-bot pushed a commit that referenced this pull request Nov 17, 2024
PR-URL: #55778
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Moshe Atlow <moshe@atlow.co.il>
Reviewed-By: Chemi Atlow <chemi@atlow.co.il>
Reviewed-By: Juan José Arboleda <soyjuanarbol@gmail.com>
Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com>
nodejs-github-bot pushed a commit that referenced this pull request Nov 17, 2024
Implements https://github.com/orgs/nodejs/discussions/41283#discussioncomment-11188239

PR-URL: #55778
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Moshe Atlow <moshe@atlow.co.il>
Reviewed-By: Chemi Atlow <chemi@atlow.co.il>
Reviewed-By: Juan José Arboleda <soyjuanarbol@gmail.com>
Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com>
@ljharb ljharb deleted the nonenums branch November 17, 2024 15:08
tpoisseau pushed a commit to tpoisseau/node that referenced this pull request Nov 21, 2024
PR-URL: nodejs#55778
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Moshe Atlow <moshe@atlow.co.il>
Reviewed-By: Chemi Atlow <chemi@atlow.co.il>
Reviewed-By: Juan José Arboleda <soyjuanarbol@gmail.com>
Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com>
tpoisseau pushed a commit to tpoisseau/node that referenced this pull request Nov 21, 2024
Implements https://github.com/orgs/nodejs/discussions/41283#discussioncomment-11188239

PR-URL: nodejs#55778
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Moshe Atlow <moshe@atlow.co.il>
Reviewed-By: Chemi Atlow <chemi@atlow.co.il>
Reviewed-By: Juan José Arboleda <soyjuanarbol@gmail.com>
Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com>
Ceres6 pushed a commit to Ceres6/node that referenced this pull request Nov 26, 2024
PR-URL: nodejs#55778
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Moshe Atlow <moshe@atlow.co.il>
Reviewed-By: Chemi Atlow <chemi@atlow.co.il>
Reviewed-By: Juan José Arboleda <soyjuanarbol@gmail.com>
Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com>
Ceres6 pushed a commit to Ceres6/node that referenced this pull request Nov 26, 2024
Implements https://github.com/orgs/nodejs/discussions/41283#discussioncomment-11188239

PR-URL: nodejs#55778
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Moshe Atlow <moshe@atlow.co.il>
Reviewed-By: Chemi Atlow <chemi@atlow.co.il>
Reviewed-By: Juan José Arboleda <soyjuanarbol@gmail.com>
Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
author ready PRs that have at least one approval, no pending requests for changes, and a CI started. commit-queue-rebase Add this label to allow the Commit Queue to land a PR in several commits. dont-land-on-v18.x PRs that should not land on the v18.x-staging branch and should not be released in v18.x. dont-land-on-v20.x PRs that should not land on the v20.x-staging branch and should not be released in v20.x. dont-land-on-v22.x PRs that should not land on the v22.x-staging branch and should not be released in v22.x. dont-land-on-v23.x PRs that should not land on the v23.x-staging branch and should not be released in v23.x. needs-ci PRs that need a full CI run. util Issues and PRs related to the built-in util module.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

10 participants