Skip to content

Conversation

@thefourtheye
Copy link
Contributor

As it is, the comments are not handled properly in REPL. So, if the
comments have ' or ", then they are treated as string literals and
the error is thrown in REPL.

This patch refactors the existing logic and groups everything in a
class.

Fixes: #3421

cc @mscdex@silverwind@ChuckLangford@Fishrock123

@thefourtheyethefourtheye added the repl Issues and PRs related to the REPL subsystem. label Oct 25, 2015
@thefourtheyethefourtheyeforce-pushed the fix-comments-in-repl branch 2 times, most recently from 67fa425 to 8179911CompareOctober 25, 2015 18:33
@mscdex
Copy link
Contributor

Copy link
Contributor

Choose a reason for hiding this comment

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

The code changes LGTM.

This being my first core review I have a question, how detailed do we get with tests? The test on line 260 is good but I don't see the same test for a single quote.

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

@ChuckLangford Thanks for the feedback. I thought I covered it in 254, but we have both tests at 257 and 260. More tests is good I guess :-) I included that now. PTAL.

As it is, the comments are not handled properly in REPL. So, if the comments have `'` or `"`, then they are treated as string literals and the error is thrown in REPL. This patch refactors the existing logic and groups everything in a class. Fixes: nodejs#3421
lib/repl.js Outdated
Copy link
Member

Choose a reason for hiding this comment

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

suggestion: use a for...of loop

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

Oh yeah, I'll change it.

@thefourtheye
Copy link
ContributorAuthor

@targos I modified the PR as per your suggestions. PTAL.

@ChuckLangford
Copy link
Contributor

LGTM

Copy link
Contributor

Choose a reason for hiding this comment

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

This is for (... of ...) on a String? I was unaware that worked.

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

@Fishrock123 It actually works.

'use strict';for(constchrof"abcd"){console.log(chr);}

Copy link
Member

Choose a reason for hiding this comment

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

It works and has the advantage to handle unicode correctly:
image

@Fishrock123
Copy link
Contributor

Seems fine so far to me.

@Fishrock123
Copy link
Contributor

LGTM if it works

@thefourtheye
Copy link
ContributorAuthor

@jasnell
Copy link
Member

semver-minor?

@thefourtheye
Copy link
ContributorAuthor

@jasnell Hmmm, wouldn't this be just a bug fix? Also, can we backport this to 4.x LTS? People who use REPL will be impacted.

@jasnell
Copy link
Member

Yes and no. If it's, "Previously the REPL didn't support comments, now it does", then it's a new feature, semver-minor, and should not land in v4.x. However, if it's, "REPL was always supposed to support comments and we consider this a regression", then a case can be made for landing it in v4.x.

@Fishrock123
Copy link
Contributor

If it helps I think this should be fixed in v4.x.

@jasnell
Copy link
Member

It does help. Getting some others from the @nodejs/tsc and @nodejs/lts teams to chime in would help also. I'm leaning towards a yes for v4.x also.

@silverwind
Copy link
Contributor

I don't see this as semver-worthy. The expectation is that you can paste any JS into the REPL, so this is a 'feature' that should've been there from the start. Also, I'd be surprised if this is not actually a regression.

thefourtheye added a commit that referenced this pull request Oct 28, 2015
As it is, the comments are not handled properly in REPL. So, if the comments have `'` or `"`, then they are treated as incomplete string literals and the error is thrown in REPL. This patch refactors the existing logic and groups everything in a class. Fixes: #3421 PR-URL: #3515 Reviewed-By: Brian White <[email protected]> Reviewed-By: Jeremiah Senkpiel <[email protected]>
@thefourtheye
Copy link
ContributorAuthor

Thanks for the review people. Landed at 6cf1910

@thefourtheyethefourtheye deleted the fix-comments-in-repl branch October 28, 2015 02:03
thefourtheye added a commit that referenced this pull request Oct 28, 2015
As it is, the comments are not handled properly in REPL. So, if the comments have `'` or `"`, then they are treated as incomplete string literals and the error is thrown in REPL. This patch refactors the existing logic and groups everything in a class. Fixes: #3421 PR-URL: #3515 Reviewed-By: Brian White <[email protected]> Reviewed-By: Jeremiah Senkpiel <[email protected]>
@jasnell
Copy link
Member

Landed in v4.x-staging in d918838

rvagg pushed a commit to rvagg/io.js that referenced this pull request Oct 29, 2015
As it is, the comments are not handled properly in REPL. So, if the comments have `'` or `"`, then they are treated as incomplete string literals and the error is thrown in REPL. This patch refactors the existing logic and groups everything in a class. Fixes: nodejs#3421 PR-URL: nodejs#3515 Reviewed-By: Brian White <[email protected]> Reviewed-By: Jeremiah Senkpiel <[email protected]>
@rvaggrvagg mentioned this pull request Oct 29, 2015
thefourtheye added a commit that referenced this pull request Oct 29, 2015
As it is, the comments are not handled properly in REPL. So, if the comments have `'` or `"`, then they are treated as incomplete string literals and the error is thrown in REPL. This patch refactors the existing logic and groups everything in a class. Fixes: #3421 PR-URL: #3515 Reviewed-By: Brian White <[email protected]> Reviewed-By: Jeremiah Senkpiel <[email protected]>
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

replIssues and PRs related to the REPL subsystem.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants

@thefourtheye@mscdex@ChuckLangford@Fishrock123@jasnell@silverwind@targos