Skip to content

util: inspect: enumerable Symbols no longer have square brackets - #55778

Closed
ljharb wants to merge 2 commits into
nodejs:mainfrom
ljharb:nonenums
Closed

util: inspect: enumerable Symbols no longer have square brackets#55778
ljharb wants to merge 2 commits into
nodejs:mainfrom
ljharb:nonenums

Conversation

@ljharb

@ljharbljharb commented Nov 8, 2024

Copy link
Copy Markdown
Member

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-botnodejs-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
Copy Markdown
MemberAuthor

cc @BridgeAR

@avivkeller

avivkeller commented Nov 8, 2024

Copy link
Copy Markdown
Member

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

@BridgeARBridgeAR left a comment

Copy link
Copy Markdown
Member

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.

Comment threadlib/internal/util/inspect.js Outdated
@avivkelleravivkeller 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
Copy Markdown
Member

@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
Copy Markdown
Member

@BridgeAR I've added semver-majorPRs 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.

@targostargos added dont-land-on-v18.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. and removed semver-major PRs that contain breaking changes and should be released in the next major version. labels Nov 8, 2024
@codecov

codecovBot commented Nov 8, 2024

Copy link
Copy Markdown

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 linesCoverage Δ
lib/internal/util/inspect.js99.95% <100.00%> (-0.05%)⬇️

... and 37 files with indirect coverage changes

@ljharb
ljharbforce-pushed the nonenums branch 2 times, most recently from 8a7eda3 to 02d01fbCompareNovember 8, 2024 13:54
@ljharb
ljharbforce-pushed the nonenums branch 5 times, most recently from 577b7e7 to f4a5af6CompareNovember 10, 2024 20:21
@ljharb

This comment was marked as resolved.

@RafaelGSSRafaelGSS added the request-ci Add this label to start a Jenkins CI on a PR. label Nov 11, 2024
@github-actionsgithub-actionsBot removed the request-ci Add this label to start a Jenkins CI on a PR. label Nov 11, 2024
@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

@marco-ippolitomarco-ippolito added the request-ci Add this label to start a Jenkins CI on a PR. label Nov 12, 2024
@github-actionsgithub-actionsBot removed the request-ci Add this label to start a Jenkins CI on a PR. label Nov 12, 2024
@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

@ljharb

Copy link
Copy Markdown
MemberAuthor

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
Copy Markdown
Collaborator

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

@marco-ippolitomarco-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
Copy Markdown
MemberAuthor

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

@RafaelGSS

Copy link
Copy Markdown
Member

It seems nodejs/build#3959

@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

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

@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

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

@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

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

@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

@ljharb

Copy link
Copy Markdown
MemberAuthor

yay, all green!

@atlowChemiatlowChemi 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-botnodejs-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
Copy Markdown
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
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

author readyPRs that have at least one approval, no pending requests for changes, and a CI started.commit-queue-rebaseAdd this label to allow the Commit Queue to land a PR in several commits.dont-land-on-v22.xPRs that should not land on the v22.x-staging branch and should not be released in v22.x.needs-ciPRs that need a full CI run.utilIssues and PRs related to the built-in util module.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

10 participants

@ljharb@avivkeller@BridgeAR@nodejs-github-bot@RafaelGSS@MoLow@juanarbol@atlowChemi@targos@marco-ippolito