This repository has been archived by the owner. It is now read-only.

Add an ".enter" REPL command to force submit in case of e.g. brace mismatch #4012

Closed
stegrams opened this Issue Sep 13, 2012 · 6 comments

Comments

Projects
None yet
3 participants
@stegrams

stegrams commented Sep 13, 2012

sys:winXP/32
node-version: 0.8.9 Binary (.exe)

I d like to have a REPL command, let say .enter, so after a wrong entry I will be able to force submission and see an error message instead of the confusing secondary prompt "..."

> new RegExp("foo","wrong modifier")
... .enter
TypeError: "wrong modifier" is not a valid modifier
    at repl:(Stack trace here)
@langpavel

This comment has been minimized.

Show comment
Hide comment
@langpavel

langpavel Sep 13, 2012

Strange.. I always solving this via Ctrl+C, but you right.
But if you give expression to eval call in repl, same happens, that suprise me.
what suprise me more is fact that
node -e 'eval(\'new RegExp\("foo","wrong modifier"\)\''
force you to console :-p ! (not sure what console, REPL should be out of the game, but I see > on each new line...)

This is definitely uglu (may be vurneable) hard bug

@bnoordhuis please (sorry Ben, you are only one "low-level" who I know :-) )

langpavel commented Sep 13, 2012

Strange.. I always solving this via Ctrl+C, but you right.
But if you give expression to eval call in repl, same happens, that suprise me.
what suprise me more is fact that
node -e 'eval(\'new RegExp\("foo","wrong modifier"\)\''
force you to console :-p ! (not sure what console, REPL should be out of the game, but I see > on each new line...)

This is definitely uglu (may be vurneable) hard bug

@bnoordhuis please (sorry Ben, you are only one "low-level" who I know :-) )

@TooTallNate

This comment has been minimized.

Show comment
Hide comment
@TooTallNate

TooTallNate Oct 1, 2012

@stegrams The specific error you're seeing in this case is actually a SyntaxError and we try to catch these false-positives. I recently fixed this edge-case (invalid RegExps) but it seems to not catch this "invalid modifiers" case. I've addressed that in TooTallNate/node@f1722a2. Can @bnoordhuis or someone review?

@langpavel The > you are seeing are likely from your shell, not from node. Try node -e "new RegExp('foo', 'wrong modifier')" instead.

As to the general request of this issue, I don't really see the need, and I'd rather fix the edge-cases where things don't work as expected.

TooTallNate commented Oct 1, 2012

@stegrams The specific error you're seeing in this case is actually a SyntaxError and we try to catch these false-positives. I recently fixed this edge-case (invalid RegExps) but it seems to not catch this "invalid modifiers" case. I've addressed that in TooTallNate/node@f1722a2. Can @bnoordhuis or someone review?

@langpavel The > you are seeing are likely from your shell, not from node. Try node -e "new RegExp('foo', 'wrong modifier')" instead.

As to the general request of this issue, I don't really see the need, and I'd rather fix the edge-cases where things don't work as expected.

@stegrams

This comment has been minimized.

Show comment
Hide comment
@stegrams

stegrams Oct 1, 2012

Hello @TooTallNate !
Fixing edge-cases will be a more elegant solution indeed but I think a statement that literaly denotes the end of command will be a more imediate patch for now and a good fallback for any similar issues in the future.
Thanks for your response

stegrams commented Oct 1, 2012

Hello @TooTallNate !
Fixing edge-cases will be a more elegant solution indeed but I think a statement that literaly denotes the end of command will be a more imediate patch for now and a good fallback for any similar issues in the future.
Thanks for your response

@TooTallNate

This comment has been minimized.

Show comment
Hide comment
@TooTallNate

TooTallNate Oct 1, 2012

I think a statement that literaly denotes the end of command will be a more imediate patch for now and a good fallback for any similar issues in the future.

I disagree, because then you'll be tempted to use that as a permanent workaround, rather then report the actual REPL bugs here.

TooTallNate commented Oct 1, 2012

I think a statement that literaly denotes the end of command will be a more imediate patch for now and a good fallback for any similar issues in the future.

I disagree, because then you'll be tempted to use that as a permanent workaround, rather then report the actual REPL bugs here.

@stegrams

This comment has been minimized.

Show comment
Hide comment
@stegrams

stegrams Dec 25, 2012

Hello everyone!

You ve done a great job by fixing this edge-case and now, in v0.8.16, I have a clear and accurate explanation in the thrown error

SyntaxError: Invalid flags supplied to RegExp constructor 'wrong modifier'

But...

I m afraid that I have to insist to my initial proposal "A REPL command to force submit" cause let say I found this chunk on a site

 var hello = function() { return "Hello world"};

And now I want to see the Node.js responce on this error which is (after running node -e)

var hello = function() { return "Hello world"};
                                ^
SyntaxError: Unexpected token &

Though from inside REPL I still have the "waiting for you" three dots.

I think it's not feasible for each and every micro-case to fix (at least for now) the edge-case but it would be a great helping hand if , in a case of a bigger chunk, I could submit anyway, bypassing REPL, so the engine's responce would guide me to correct my mistake.

Thanx again and I wish a Merry Xmas to all!

stegrams commented Dec 25, 2012

Hello everyone!

You ve done a great job by fixing this edge-case and now, in v0.8.16, I have a clear and accurate explanation in the thrown error

SyntaxError: Invalid flags supplied to RegExp constructor 'wrong modifier'

But...

I m afraid that I have to insist to my initial proposal "A REPL command to force submit" cause let say I found this chunk on a site

 var hello = function() { return "Hello world"};

And now I want to see the Node.js responce on this error which is (after running node -e)

var hello = function() { return "Hello world"};
                                ^
SyntaxError: Unexpected token &

Though from inside REPL I still have the "waiting for you" three dots.

I think it's not feasible for each and every micro-case to fix (at least for now) the edge-case but it would be a great helping hand if , in a case of a bigger chunk, I could submit anyway, bypassing REPL, so the engine's responce would guide me to correct my mistake.

Thanx again and I wish a Merry Xmas to all!

@stegrams

This comment has been minimized.

Show comment
Hide comment
@stegrams

stegrams Jan 1, 2013

@TooTallNate will you please reopen this issue
Thanks

stegrams commented Jan 1, 2013

@TooTallNate will you please reopen this issue
Thanks

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