repl: do not consider ... as a REPL command#14467
repl: do not consider ... as a REPL command#14467shivanth wants to merge 5 commits intonodejs:masterfrom
... as a REPL command#14467Conversation
This fix makes ... in REPL to be considered as a javascript construct rather than a REPL keyword Fixes: nodejs#14426
Trott
left a comment
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
|
Change looks good. For adding a test, check out https://github.com/nodejs/node/blob/master/test/parallel/test-repl.js. |
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))) { |
There was a problem hiding this comment.
Please use strict not equals, so trimmedCmd.charAt(1) !== '.'
|
FWIW commit message is missing a space after the colon. |
... as a REPL command... as a REPL command
|
@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. |
|
P.S. as far as I can see this change also enables |
|
@refack The I came across this when I tried to add a new test case |
That's something that should be investigated separately. Any kind of invalid syntax does it, but is has its uses too: Same also works on the shell: The question is if it can be determined if a line can never be valid, like As a first step, I'm fine if you just make sure it not gets parsed as a REPL command. |
|
Because my test case is leaving the REPL in an inconsistent state, the tests that follow my new test fails ... |
|
Done 👍 |
|
The test as it stands right now does not fail on current master so it is not testing the feature implemented here. |
| { 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?
There was a problem hiding this comment.
It passes as we do not use the spaced-comment rule. I fixed it anyways.
|
Thanks, landed in 46d3ff2! I fixed the whitespace issues in the test and wrapped the long line in |
|
Should this be backported to |
|
I'd say so. @shivanth wanna do it? |
|
I'm in 👍 |
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' I found #18915, but its a PR... |
This fix makes
...in REPL to be considered as a javascript constructrather than a REPL keyword
Fixes: #14426
Checklist
make -j4 test(UNIX), orvcbuild test(Windows) passesAffected core subsystem(s)
repl