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

repl: Don’t complete expressions when eval() failed #6328

Closed
wants to merge 1 commit into from

Conversation

addaleax
Copy link
Member

Checklist
  • tests and code linting passes
  • a test and/or benchmark is included
  • the commit message follows commit guidelines
Affected core subsystem(s)

repl

Description of change

Instead of changing the way “simple” expressions are detected, switch to ignoring errors when completing. This approach is more generic than the previous one from 0b66b8f, but also changes the way errors are thrown when completing.

Fixes: #6325

This includes a revert of the regular expression change in #6192.
This is also a completely inappropriate solution if it is intended that trying to complete expressions like a = b.c.d with b not defined throw a ReferenceError; the test file seems to be laid out to expect that behaviour. I can’t imagine how that might be even remotely desirable, though.

@addaleax addaleax added the repl Issues and PRs related to the REPL subsystem. label Apr 21, 2016
@addaleax
Copy link
Member Author

@targos targos added this to the 6.0.0 milestone Apr 21, 2016
@Trott
Copy link
Member

Trott commented Apr 21, 2016

I agree about the ReferenceError behavior being undesirable. Changing it probably makes this semver-major, I think, especially since the test file makes it clear that the behavior was expected.

With 6.0 landing next week, it's a good time to be semver-major!

@Trott Trott added the semver-major PRs that contain breaking changes and should be released in the next major version. label Apr 21, 2016
@jasnell
Copy link
Member

jasnell commented Apr 22, 2016

This LGTM but would like to get more review from @nodejs/ctc

@@ -806,7 +806,8 @@ REPLServer.prototype.complete = function(line, callback) {
});
}
} else {
this.eval(expr, this.context, 'repl', function(e, obj) {
const evalExpr = `try { ${expr} } catch (e) { undefined }`;
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think the undefined is necessary.

Copy link
Member Author

Choose a reason for hiding this comment

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

You’re right. If you want it removed, sure, but I don’t mind the verbosity of writing the “return” value down explicitly.

Copy link
Contributor

Choose a reason for hiding this comment

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

I would drop it.

@cjihrig
Copy link
Contributor

cjihrig commented Apr 22, 2016

LGTM with a comment.

@addaleax
Copy link
Member Author

Rebased & updated with @cjihrig’s suggestion.

@jasnell
Copy link
Member

jasnell commented Apr 22, 2016

@addaleax
Copy link
Member Author

@jasnell This one too? I’ll gladly to wait for more LGTMs, but it might be nice to have it in the rc, at least if that’s going to be the last one before the actual release (which I assume it is?). CI looks good.

@jasnell
Copy link
Member

jasnell commented Apr 22, 2016

Let's give this one until Monday just to make sure there are no other objections.

@nodejs/ctc ... please take a moment to take a look!

Instead of changing the way “simple” expressions are detected,
switch to ignoring errors when completing. This approach is more
generic than the previous one from 0b66b8f, but also changes
the way errors are thrown when completing.

This reverts the code changes from commit 0b66b8f.
The test case is left intact.

Fixes: nodejs#6325
PR-URL: nodejs#6328
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
@addaleax
Copy link
Member Author

Squashed & rebased against master, and updated the added tests to use deepStrictEqual instead of deepEqual. One more CI: https://ci.nodejs.org/job/node-test-commit/3046/

@jasnell
Copy link
Member

jasnell commented Apr 25, 2016

LGTM after squashing, CI is green. Landing this in a minute

jasnell pushed a commit that referenced this pull request Apr 25, 2016
Instead of changing the way “simple” expressions are detected,
switch to ignoring errors when completing. This approach is more
generic than the previous one from 0b66b8f, but also changes
the way errors are thrown when completing.

This reverts the code changes from commit 0b66b8f.
The test case is left intact.

Fixes: #6325
PR-URL: #6328
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
@jasnell
Copy link
Member

jasnell commented Apr 25, 2016

Landed in 3ee68f7

@jasnell jasnell closed this Apr 25, 2016
@addaleax addaleax deleted the repl-no-reference-errors branch April 25, 2016 16:44
jasnell pushed a commit that referenced this pull request Apr 26, 2016
Instead of changing the way “simple” expressions are detected,
switch to ignoring errors when completing. This approach is more
generic than the previous one from 0b66b8f, but also changes
the way errors are thrown when completing.

This reverts the code changes from commit 0b66b8f.
The test case is left intact.

Fixes: #6325
PR-URL: #6328
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
repl Issues and PRs related to the REPL subsystem. semver-major PRs that contain breaking changes and should be released in the next major version.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants