repl: Don’t complete expressions when eval() failed #6328
Conversation
I agree about the With 6.0 landing next week, it's a good time to be |
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 }`; |
cjihrig
Apr 22, 2016
Contributor
I don't think the undefined
is necessary.
I don't think the undefined
is necessary.
addaleax
Apr 22, 2016
Author
Member
You’re right. If you want it removed, sure, but I don’t mind the verbosity of writing the “return” value down explicitly.
You’re right. If you want it removed, sure, but I don’t mind the verbosity of writing the “return” value down explicitly.
cjihrig
Apr 22, 2016
Contributor
I would drop it.
I would drop it.
LGTM with a comment. |
Rebased & updated with @cjihrig’s suggestion. |
@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. |
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: #6325 PR-URL: #6328 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Squashed & rebased against master, and updated the added tests to use |
LGTM after squashing, CI is green. Landing this in a minute |
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>
Landed in 3ee68f7 |
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>
Checklist
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
withb
not defined throw aReferenceError
; the test file seems to be laid out to expect that behaviour. I can’t imagine how that might be even remotely desirable, though.