| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Sorry, something went wrong.
This fix makes ... in REPL to be considered as a javascript construct rather than a REPL keyword Fixes: nodejs#14426
There was a problem hiding this comment.
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
Sorry, something went wrong.
|
Change looks good. For adding a test, check out https://github.com/nodejs/node/blob/master/test/parallel/test-repl.js. |
Sorry, something went wrong.
| // display next prompt and return. | ||
| if (trimmedCmd) { | ||
| if (trimmedCmd.charAt(0) === '.' && isNaN(parseFloat(trimmedCmd))) { | ||
| if (trimmedCmd.charAt(0) === '.' && trimmedCmd.charAt(1) != '.' && isNaN(parseFloat(trimmedCmd))) { |
There was a problem hiding this comment.
Please use strict not equals, so trimmedCmd.charAt(1) !== '.'
Sorry, something went wrong.
|
FWIW commit message is missing a space after the colon. |
Sorry, something went wrong.
|
@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. |
Sorry, something went wrong.
|
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. |
Sorry, something went wrong.
|
@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 |
Sorry, something went wrong.
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. |
Sorry, something went wrong.
|
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/
|
Sorry, something went wrong.
|
Done 👍 |
Sorry, something went wrong.
Sorry, something went wrong.
|
The test as it stands right now does not fail on current master so it is not testing the feature implemented here. |
Sorry, something went wrong.
Sorry, something went wrong.
There was a problem hiding this comment.
Sorry, something went wrong.
| { client: client_unix, send: ' \t \n', | ||
| expect: prompt_unix } | ||
| expect: prompt_unix }, | ||
| //Do not parse `...[]` as a REPL keyword |
There was a problem hiding this comment.
the linter might fail due to no space between the comment start?
Sorry, something went wrong.
There was a problem hiding this comment.
It passes as we do not use the spaced-comment rule. I fixed it anyways.
Sorry, something went wrong.
|
Thanks, landed in 46d3ff2! I fixed the whitespace issues in the test and wrapped the long line in lib so it passed the linter. |
Sorry, something went wrong.
|
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. |
Sorry, something went wrong.
|
I'm in 👍 |
Sorry, something went wrong.
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>
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>
|
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... |
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
This fix makes ... in REPL to be considered as a javascript construct
rather than a REPL keyword
Fixes: #14426
Checklist
Affected core subsystem(s)
repl