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
base: master
from

Conversation

Projects
None yet
5 participants
@addaleax
Member

addaleax commented Apr 21, 2016

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 label Apr 21, 2016

@addaleax

This comment has been minimized.

Member

addaleax commented Apr 21, 2016

@addaleax addaleax force-pushed the addaleax:repl-no-reference-errors branch Apr 21, 2016

@targos targos added this to the 6.0.0 milestone Apr 21, 2016

@Trott

This comment has been minimized.

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 label Apr 21, 2016

@jasnell

This comment has been minimized.

Member

jasnell commented Apr 22, 2016

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

@cjihrig

View changes

lib/repl.js Outdated
@@ -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 }`;

This comment has been minimized.

@cjihrig

cjihrig Apr 22, 2016

Contributor

I don't think the undefined is necessary.

This comment has been minimized.

@addaleax

addaleax Apr 22, 2016

Member

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

This comment has been minimized.

@cjihrig

cjihrig Apr 22, 2016

Contributor

I would drop it.

@cjihrig

This comment has been minimized.

Contributor

cjihrig commented Apr 22, 2016

LGTM with a comment.

@addaleax addaleax force-pushed the addaleax:repl-no-reference-errors branch Apr 22, 2016

@addaleax

This comment has been minimized.

Member

addaleax commented Apr 22, 2016

Rebased & updated with @cjihrig’s suggestion.

@jasnell

This comment has been minimized.

Member

jasnell commented Apr 22, 2016

@addaleax

This comment has been minimized.

Member

addaleax commented Apr 22, 2016

@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

This comment has been minimized.

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!

repl: don’t complete expressions when eval fails
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>

@addaleax addaleax force-pushed the addaleax:repl-no-reference-errors branch to 05d4103 Apr 25, 2016

@addaleax

This comment has been minimized.

Member

addaleax commented Apr 25, 2016

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

This comment has been minimized.

Member

jasnell commented Apr 25, 2016

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

jasnell added a commit that referenced this pull request Apr 25, 2016

repl: don’t complete expressions when eval fails
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

This comment has been minimized.

Member

jasnell commented Apr 25, 2016

Landed in 3ee68f7

@jasnell jasnell closed this Apr 25, 2016

@addaleax addaleax deleted the addaleax:repl-no-reference-errors branch Apr 25, 2016

jasnell added a commit that referenced this pull request Apr 26, 2016

repl: don’t complete expressions when eval fails
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