Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 34.3k
repl: fix tab completion not working with computer string properties#58709
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
repl: fix tab completion not working with computer string properties #58709
Uh oh!
There was an error while loading. Please reload this page.
Conversation
66a2820 to 9cbd60dComparecodecovbot commented Jun 15, 2025 • edited
Loading Uh oh!
There was an error while loading. Please reload this page.
edited
Uh oh!
There was an error while loading. Please reload this page.
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@## main #58709 +/- ## ======================================= Coverage 90.12% 90.13% ======================================= Files 637 637 Lines 188121 188121 Branches 36892 36892 ======================================= + Hits 169552 169568 +16 - Misses 11313 11316 +3 + Partials 7256 7237 -19
🚀 New features to boost your workflow:
|
9cbd60d to 3dec780Compare3dec780 to da0d780Compare This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
nodejs-github-bot commented Jun 16, 2025
BridgeAR left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That is definitely a nice improvement!
We'd better use acorn to detect these things in the future though. We are for example still missing support for whitespace in-between. We also miss support for partial matches inside of a bracket. That would also be great.
0722023 into nodejs:mainUh oh!
There was an error while loading. Please reload this page.
nodejs-github-bot commented Jun 17, 2025
Landed in 0722023 |
dario-piotrowicz commented Jun 17, 2025
I 100% agree, as I mentioned in the PR description this was a first fix I figured I could already land (it also already includes some new tests which will help assuring that changes later work as intended) I'll most likely be using acron on my next iteration here, also I really really want to get rid of this regex: Lines 1228 to 1229 in da0d780
😁 (since it's very complex and not even fully correct)
Can you elaborate? 🙂 |
PR-URL: #58709 Reviewed-By: Yagiz Nizipli <[email protected]> Reviewed-By: Ruben Bridgewater <[email protected]>
PR-URL: #58709 Reviewed-By: Yagiz Nizipli <[email protected]> Reviewed-By: Ruben Bridgewater <[email protected]>
PR-URL: #58709 Reviewed-By: Yagiz Nizipli <[email protected]> Reviewed-By: Ruben Bridgewater <[email protected]>
PR-URL: #58709 Reviewed-By: Yagiz Nizipli <[email protected]> Reviewed-By: Ruben Bridgewater <[email protected]>
PR-URL: #58709 Reviewed-By: Yagiz Nizipli <[email protected]> Reviewed-By: Ruben Bridgewater <[email protected]>
PR-URL: #58709 Reviewed-By: Yagiz Nizipli <[email protected]> Reviewed-By: Ruben Bridgewater <[email protected]>
PR-URL: #58709 Reviewed-By: Yagiz Nizipli <[email protected]> Reviewed-By: Ruben Bridgewater <[email protected]>
PR-URL: #58709 Reviewed-By: Yagiz Nizipli <[email protected]> Reviewed-By: Ruben Bridgewater <[email protected]>
PR-URL: #58709 Reviewed-By: Yagiz Nizipli <[email protected]> Reviewed-By: Ruben Bridgewater <[email protected]>
PR-URL: #58709 Reviewed-By: Yagiz Nizipli <[email protected]> Reviewed-By: Ruben Bridgewater <[email protected]>
PR-URL: #58709 Reviewed-By: Yagiz Nizipli <[email protected]> Reviewed-By: Ruben Bridgewater <[email protected]>
PR-URL: #58709 Reviewed-By: Yagiz Nizipli <[email protected]> Reviewed-By: Ruben Bridgewater <[email protected]>
PR-URL: #58709 Reviewed-By: Yagiz Nizipli <[email protected]> Reviewed-By: Ruben Bridgewater <[email protected]>
A number of recent changes to the REPL tab completion logic have introduced the ability for completion to cause side effects, specifically, calling arbitrary functions or variable assignments/updates. This was first introduced in 0722023 and the problem exacerbated in 8ba66c5. Our team noticed this because our tests started failing when attempting to update to Node.js 20.19.5. Some recent commits, such as 1093f38 or 6945337, have messages or PR descriptions that imply the intention to avoid side effects, which I can can generally be agreed upon is in line with the expectations that a user has of autocomplete functionality. However, some of the tests introduced in those commts specifically verify that side effects *can* happen under specific circunmstances. I am assuming here that this is unintentional, and the corresponding tests have been removed/replaced in this commit. Refs: nodejs#58709 Refs: nodejs#58775 Refs: nodejs#57909 Refs: nodejs#58891
A number of recent changes to the REPL tab completion logic have introduced the ability for completion to cause side effects, specifically, calling arbitrary functions or variable assignments/updates. This was first introduced in 0722023 and the problem exacerbated in 8ba66c5. Our team noticed this because our tests started failing when attempting to update to Node.js 20.19.5. Some recent commits, such as 1093f38 or 6945337, have messages or PR descriptions that imply the intention to avoid side effects, which I can can generally be agreed upon is in line with the expectations that a user has of autocomplete functionality. However, some of the tests introduced in those commts specifically verify that side effects *can* happen under specific circunmstances. I am assuming here that this is unintentional, and the corresponding tests have been removed/replaced in this commit. Refs: nodejs#58709 Refs: nodejs#58775 Refs: nodejs#57909 Refs: nodejs#58891
A number of recent changes to the REPL tab completion logic have introduced the ability for completion to cause side effects, specifically, calling arbitrary functions or variable assignments/updates. This was first introduced in 0722023 and the problem exacerbated in 8ba66c5. Our team noticed this because our tests started failing when attempting to update to Node.js 20.19.5. Some recent commits, such as 1093f38 or 6945337, have messages or PR descriptions that imply the intention to avoid side effects, which I can can generally be agreed upon is in line with the expectations that a user has of autocomplete functionality. However, some of the tests introduced in those commts specifically verify that side effects *can* happen under specific circunmstances. I am assuming here that this is unintentional, and the corresponding tests have been removed/replaced in this commit. Refs: nodejs#58709 Refs: nodejs#58775 Refs: nodejs#57909 Refs: nodejs#58891
A number of recent changes to the REPL tab completion logic have introduced the ability for completion to cause side effects, specifically, calling arbitrary functions or variable assignments/updates. This was first introduced in 0722023 and the problem exacerbated in 8ba66c5. Our team noticed this because our tests started failing when attempting to update to Node.js 20.19.5. Some recent commits, such as 1093f38 or 6945337, have messages or PR descriptions that imply the intention to avoid side effects, which I can can generally be agreed upon is in line with the expectations that a user has of autocomplete functionality. However, some of the tests introduced in those commts specifically verify that side effects *can* happen under specific circunmstances. I am assuming here that this is unintentional, and the corresponding tests have been removed/replaced in this commit. Fixes: nodejs#58903 Refs: nodejs#58709 Refs: nodejs#58775 Refs: nodejs#57909 Refs: nodejs#58891
A number of recent changes to the REPL tab completion logic have introduced the ability for completion to cause side effects, specifically, calling arbitrary functions or variable assignments/updates. This was first introduced in 0722023 and the problem exacerbated in 8ba66c5. Our team noticed this because our tests started failing when attempting to update to Node.js 20.19.5. Some recent commits, such as 1093f38 or 6945337, have messages or PR descriptions that imply the intention to avoid side effects, which I can can generally be agreed upon is in line with the expectations that a user has of autocomplete functionality. However, some of the tests introduced in those commts specifically verify that side effects *can* happen under specific circunmstances. I am assuming here that this is unintentional, and the corresponding tests have been removed/replaced in this commit. Fixes: nodejs#59731Fixes: nodejs#58903 Refs: nodejs#58709 Refs: nodejs#58775 Refs: nodejs#57909 Refs: nodejs#58891
A number of recent changes to the REPL tab completion logic have introduced the ability for completion to cause side effects, specifically, calling arbitrary functions or variable assignments/updates. This was first introduced in 0722023 and the problem exacerbated in 8ba66c5. Our team noticed this because our tests started failing when attempting to update to Node.js 20.19.5. Some recent commits, such as 1093f38 or 6945337, have messages or PR descriptions that imply the intention to avoid side effects, which I can can generally be agreed upon is in line with the expectations that a user has of autocomplete functionality. However, some of the tests introduced in those commts specifically verify that side effects *can* happen under specific circunmstances. I am assuming here that this is unintentional, and the corresponding tests have been removed/replaced in this commit. Fixes: #59731Fixes: #58903 Refs: #58709 Refs: #58775 Refs: #57909 Refs: #58891 PR-URL: #59774 Reviewed-By: Ruben Bridgewater <[email protected]> Reviewed-By: Michaël Zasso <[email protected]> Reviewed-By: Dario Piotrowicz <[email protected]>
A number of recent changes to the REPL tab completion logic have introduced the ability for completion to cause side effects, specifically, calling arbitrary functions or variable assignments/updates. This was first introduced in 0722023 and the problem exacerbated in 8ba66c5. Our team noticed this because our tests started failing when attempting to update to Node.js 20.19.5. Some recent commits, such as 1093f38 or 6945337, have messages or PR descriptions that imply the intention to avoid side effects, which I can can generally be agreed upon is in line with the expectations that a user has of autocomplete functionality. However, some of the tests introduced in those commts specifically verify that side effects *can* happen under specific circunmstances. I am assuming here that this is unintentional, and the corresponding tests have been removed/replaced in this commit. Fixes: #59731Fixes: #58903 Refs: #58709 Refs: #58775 Refs: #57909 Refs: #58891 PR-URL: #59774 Reviewed-By: Ruben Bridgewater <[email protected]> Reviewed-By: Michaël Zasso <[email protected]> Reviewed-By: Dario Piotrowicz <[email protected]>
I noticed that the repl tab completion doesn't correctly handle computed properties targeted by strings.
For example given the following context:
The current repl would provide valid (number) completions for lines such as:
But would not provide correct completions for lines such as:
In fact it would provide incorrect (string) completions.
See:

This PR addresses the above issue
Note
This PR is not making everything work perfectly, for example it is not addressing lines such as
obj['o' + 'ne'].to(but it's not making them any worse either).I think that a generally great solution would require more substantial code changes (potentially with some AST analysis).
I am planning on keeping improving things here but I figured I could do it incrementally and that I'd open this PR to
start moving things in the right direction anyways.