joyent/node — Issue #2746: No Error for Malformed Groups in Regex in REPL
Author: Mortchek
Created: 2012-02-13 05:25:39+00:00
State: open

When the REPL tries to execute a regex which contains a malformed group, it prints the same "..." it would usually print when the input contains a syntax error or is incomplete in itself. e.g.,

> 'hello'.find(/(h/);
...

This is less a problem when entering it directly in the same line, but it becomes a greater issue when the regex in question is in a called function, which could be in an included module, and runs counter to the usual meaning of "...", which is that immediate input is syntactically incomplete.

> function find_h(s) { return s.find(/(h/); }
undefined
> find_h('hello');
....

Instead it would be much more helpful if it printed an actual error, something along the lines of what a browser might print, such as the following error message from Chrome:

SyntaxError: Invalid regular expression: /(h/: Unterminated group