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: do not consider `...` as a REPL command #14467

Closed
wants to merge 5 commits into
base: master
from

Conversation

Projects
None yet
@shivanth
Contributor

shivanth commented Jul 25, 2017

This fix makes ... in REPL to be considered as a javascript construct
rather than a REPL keyword

Fixes: #14426

Checklist
  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • tests and/or benchmarks are included
  • commit message follows commit guidelines
Affected core subsystem(s)

repl

repl:Do not consider `...` as a REPL command
This fix makes ... in REPL to be considered as a javascript construct
rather than a REPL keyword

Fixes: #14426
@Trott

Thanks for the contribution! Please add a test! REPL tests can be tricky, but this is probably something that can be tested by adding something to test/parallel/test-repl.js. Additional info about our tests in general can be found in https://github.com/nodejs/node/blob/master/doc/guides/writing-tests.md

@silverwind

This comment has been minimized.

Show comment
Hide comment
@silverwind

silverwind Jul 25, 2017

Contributor

Change looks good. For adding a test, check out https://github.com/nodejs/node/blob/master/test/parallel/test-repl.js.

Contributor

silverwind commented Jul 25, 2017

Change looks good. For adding a test, check out https://github.com/nodejs/node/blob/master/test/parallel/test-repl.js.

Show outdated Hide outdated lib/repl.js
@mscdex

This comment has been minimized.

Show comment
Hide comment
@mscdex

mscdex Jul 25, 2017

Contributor

FWIW commit message is missing a space after the colon.

Contributor

mscdex commented Jul 25, 2017

FWIW commit message is missing a space after the colon.

@refack refack changed the title from repl:vDo not consider `...` as a REPL command to repl: do not consider `...` as a REPL command Jul 25, 2017

@refack

This comment has been minimized.

Show comment
Hide comment
@refack

refack Jul 25, 2017

Member

@shivanth thank for your contribution 🥇. Don't be alarmed by all the reviews, as far as I can see they are just in order to make your submission even better. I would really want to see you follow up, so this PR will land.

Member

refack commented Jul 25, 2017

@shivanth thank for your contribution 🥇. Don't be alarmed by all the reviews, as far as I can see they are just in order to make your submission even better. I would really want to see you follow up, so this PR will land.

@refack

This comment has been minimized.

Show comment
Hide comment
@refack

refack Jul 25, 2017

Member

P.S. as far as I can see this change also enables ..* to be treated as a non REPL command. IMHO that's good since it's just as invalid as ...[] 👍 So when you add a test, try that as well.

Member

refack commented Jul 25, 2017

P.S. as far as I can see this change also enables ..* to be treated as a non REPL command. IMHO that's good since it's just as invalid as ...[] 👍 So when you add a test, try that as well.

@shivanth

This comment has been minimized.

Show comment
Hide comment
@shivanth

shivanth Jul 25, 2017

Contributor

@refack The...command seems to put the repl into an inconsistent state, it always shows up a multiline command, which can only be exited by pressing ctrl-c.


> ..save
... dad
... ()
... blah
...
>

I came across this when I tried to add a new test case

Contributor

shivanth commented Jul 25, 2017

@refack The...command seems to put the repl into an inconsistent state, it always shows up a multiline command, which can only be exited by pressing ctrl-c.


> ..save
... dad
... ()
... blah
...
>

I came across this when I tried to add a new test case

@silverwind

This comment has been minimized.

Show comment
Hide comment
@silverwind

silverwind Jul 25, 2017

Contributor

The...command seems to put the repl into an inconsistent state

That's something that should be investigated separately. Any kind of invalid syntax does it, but is has its uses too:

> a=
... 1;
1

Same also works on the shell:

$ node -p "a=\
dquote> 1"
1

The question is if it can be determined if a line can never be valid, like ...something, so we don't show the line continuation and output the error immediately, but I guess this can get complex.

As a first step, I'm fine if you just make sure it not gets parsed as a REPL command.

Contributor

silverwind commented Jul 25, 2017

The...command seems to put the repl into an inconsistent state

That's something that should be investigated separately. Any kind of invalid syntax does it, but is has its uses too:

> a=
... 1;
1

Same also works on the shell:

$ node -p "a=\
dquote> 1"
1

The question is if it can be determined if a line can never be valid, like ...something, so we don't show the line continuation and output the error immediately, but I guess this can get complex.

As a first step, I'm fine if you just make sure it not gets parsed as a REPL command.

@shivanth

This comment has been minimized.

Show comment
Hide comment
@shivanth

shivanth Jul 26, 2017

Contributor

Because my test case is leaving the REPL in an inconsistent state, the tests that follow my new test fails ...

sending "...[]"
Unix data: "... ", expecting "... "
sending "ref = 1"
Unix data: "... ", expecting /^ReferenceError:\sref\sis\snot\sdefined\n\s+at\srepl:1:5/
assert.js:43
  throw new errors.AssertionError({
  ^

AssertionError [ERR_ASSERTION]: '... ' === /^ReferenceError:\sref\sis\snot\sdefined\n\s+at\srepl:1:5/
Contributor

shivanth commented Jul 26, 2017

Because my test case is leaving the REPL in an inconsistent state, the tests that follow my new test fails ...

sending "...[]"
Unix data: "... ", expecting "... "
sending "ref = 1"
Unix data: "... ", expecting /^ReferenceError:\sref\sis\snot\sdefined\n\s+at\srepl:1:5/
assert.js:43
  throw new errors.AssertionError({
  ^

AssertionError [ERR_ASSERTION]: '... ' === /^ReferenceError:\sref\sis\snot\sdefined\n\s+at\srepl:1:5/
@shivanth

This comment has been minimized.

Show comment
Hide comment
@shivanth

shivanth Jul 26, 2017

Contributor

Done 👍

Contributor

shivanth commented Jul 26, 2017

Done 👍

@shivanth

This comment has been minimized.

Show comment
Hide comment
@shivanth
Contributor

shivanth commented Jul 27, 2017

@Trott

This comment has been minimized.

Show comment
Hide comment
@Trott

Trott Jul 27, 2017

Member

The test as it stands right now does not fail on current master so it is not testing the feature implemented here.

Member

Trott commented Jul 27, 2017

The test as it stands right now does not fail on current master so it is not testing the feature implemented here.

@Trott Trott dismissed their stale review Jul 27, 2017

test added, dismissing review

@Trott

This comment has been minimized.

Show comment
Hide comment
Member

Trott commented Jul 27, 2017

@@ -414,7 +414,14 @@ function error_test() {
expect: `${prompt_multiline}'foo \\n'\n${prompt_unix}` },
// Whitespace is not evaluated.
{ client: client_unix, send: ' \t \n',
expect: prompt_unix }
expect: prompt_unix },
//Do not parse `...[]` as a REPL keyword

This comment has been minimized.

@Fishrock123

Fishrock123 Jul 27, 2017

Member

the linter might fail due to no space between the comment start?

@Fishrock123

Fishrock123 Jul 27, 2017

Member

the linter might fail due to no space between the comment start?

This comment has been minimized.

@silverwind

silverwind Jul 29, 2017

Contributor

It passes as we do not use the spaced-comment rule. I fixed it anyways.

@silverwind

silverwind Jul 29, 2017

Contributor

It passes as we do not use the spaced-comment rule. I fixed it anyways.

@silverwind

This comment has been minimized.

Show comment
Hide comment
@silverwind

silverwind Jul 29, 2017

Contributor

Thanks, landed in 46d3ff2!

I fixed the whitespace issues in the test and wrapped the long line in lib so it passed the linter.

Contributor

silverwind commented Jul 29, 2017

Thanks, landed in 46d3ff2!

I fixed the whitespace issues in the test and wrapped the long line in lib so it passed the linter.

@silverwind silverwind closed this Jul 29, 2017

addaleax added a commit that referenced this pull request Jul 29, 2017

repl: do not consider `...` as a REPL command
This fix makes ... in REPL to be considered as a javascript construct
rather than a REPL keyword.

Fixes: #14426
PR-URL: #14467
Reviewed-By: Roman Reiss <me@silverwind.io>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com>

@addaleax addaleax referenced this pull request Aug 2, 2017

Merged

v8.3.0 proposal #14594

@MylesBorins

This comment has been minimized.

Show comment
Hide comment
@MylesBorins

MylesBorins Aug 16, 2017

Member

Should this be backported to v6.x-staging? If yes please follow the guide and raise a backport PR, if no let me know or add the dont-land-on label.

Member

MylesBorins commented Aug 16, 2017

Should this be backported to v6.x-staging? If yes please follow the guide and raise a backport PR, if no let me know or add the dont-land-on label.

@silverwind

This comment has been minimized.

Show comment
Hide comment
@silverwind

silverwind Aug 16, 2017

Contributor

I'd say so. @shivanth wanna do it?

Contributor

silverwind commented Aug 16, 2017

I'd say so. @shivanth wanna do it?

@shivanth

This comment has been minimized.

Show comment
Hide comment
@shivanth

shivanth Aug 16, 2017

Contributor

I'm in 👍

Contributor

shivanth commented Aug 16, 2017

I'm in 👍

shivanth added a commit to shivanth/node that referenced this pull request Aug 18, 2017

repl: do not consider `...` as a REPL command
This fix makes ... in REPL to be considered as a javascript construct
rather than a REPL keyword.

Fixes: nodejs#14426
PR-URL: nodejs#14467
Reviewed-By: Roman Reiss <me@silverwind.io>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com>

MylesBorins added a commit that referenced this pull request Sep 19, 2017

repl: do not consider `...` as a REPL command
This fix makes ... in REPL to be considered as a javascript construct
rather than a REPL keyword.

Fixes: #14426
Backport-PR-URL: #14915
PR-URL: #14467
Reviewed-By: Roman Reiss <me@silverwind.io>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com>

@MylesBorins MylesBorins referenced this pull request Sep 20, 2017

Merged

v6.11.4 proposal #15506

@0joshuaolson1

This comment has been minimized.

Show comment
Hide comment
@0joshuaolson1

0joshuaolson1 Feb 27, 2018

Was an issue ever created for the aforementioned problem where some syntax errors put the repl in an 'inconsistent' ... state until you Ctrl+C?

I found #18915, but its a PR...

0joshuaolson1 commented Feb 27, 2018

Was an issue ever created for the aforementioned problem where some syntax errors put the repl in an 'inconsistent' ... state until you Ctrl+C?

I found #18915, but its a PR...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment