FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

repl: do not consider `...` as a REPL command by shivanth · Pull Request #14467 · nodejs/node · GitHub

/ node Public

repl: do not consider ... as a REPL command - #14467

Closed
shivanth wants to merge 5 commits into
nodejs:masterfrom
shivanth:repl_fix
Closed

repl: do not consider ... as a REPL command#14467
shivanth wants to merge 5 commits into
nodejs:masterfrom
shivanth:repl_fix

Conversation

shivanth commented Jul 25, 2017
edited
Loading

Copy link
Copy Markdown
Contributor

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

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

Fixes: nodejs#14426
nodejs-github-bot added the repl Issues and PRs related to the REPL subsystem. label Jul 25, 2017
Trott previously requested changes Jul 25, 2017

Trott left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

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

Copy link
Copy Markdown
Contributor

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

Comment thread lib/repl.js Outdated
// display next prompt and return.
if (trimmedCmd) {
if (trimmedCmd.charAt(0) === '.' && isNaN(parseFloat(trimmedCmd))) {
if (trimmedCmd.charAt(0) === '.' && trimmedCmd.charAt(1) != '.' && isNaN(parseFloat(trimmedCmd))) {

TimothyGu Jul 25, 2017
edited
Loading

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Please use strict not equals, so trimmedCmd.charAt(1) !== '.'

mscdex commented Jul 25, 2017

Copy link
Copy Markdown
Contributor

FWIW commit message is missing a space after the colon.

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

refack commented Jul 25, 2017

Copy link
Copy Markdown
Contributor

@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 commented Jul 25, 2017

Copy link
Copy Markdown
Contributor

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.

Copy link
Copy Markdown
Contributor Author

@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

Copy link
Copy Markdown
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.

Copy link
Copy Markdown
Contributor Author

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/

Copy link
Copy Markdown
Contributor Author

Done 👍

Copy link
Copy Markdown
Contributor Author

@Trott @TimothyGu

Trott commented Jul 27, 2017

Copy link
Copy Markdown
Member

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

Trott dismissed their stale review July 27, 2017 20:47

test added, dismissing review

Trott commented Jul 27, 2017

Copy link
Copy Markdown
Member

Fishrock123 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

{ client: client_unix, send: ' \t \n',
expect: prompt_unix }
expect: prompt_unix },
//Do not parse `...[]` as a REPL keyword

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

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

Copy link
Copy Markdown
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.

silverwind closed this Jul 29, 2017
addaleax pushed a commit that referenced this pull request Jul 29, 2017
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 mentioned this pull request Aug 2, 2017

Copy link
Copy Markdown
Contributor

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.

Copy link
Copy Markdown
Contributor

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

Copy link
Copy Markdown
Contributor Author

I'm in 👍

shivanth added a commit to shivanth/node that referenced this pull request Aug 18, 2017
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 pushed a commit that referenced this pull request Sep 19, 2017
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 mentioned this pull request Sep 20, 2017

Copy link
Copy Markdown

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...

This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
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.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

repl: '...' should not be detected as REPL keyword

Back | FazBrowse Home | New Git URL