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

Open
wants to merge 2 commits into
base: main
Choose a base branch
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

@RedYetiDev
Copy link
Member

RedYetiDev 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
@RedYetiDev RedYetiDev 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.

@RedYetiDev
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/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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.

8 participants