RegExp.source should return a valid pattern |
||||||
Issue description(new RegExp()).source now returns '(:?)' in JSC, whereas it returns '' in V8. JSC just changed their behavior, see https://bugs.webkit.org/show_bug.cgi?id=79938 for their reasoning (the short answer is that it matches the pattern generated by toString()). For now I'm suppressing this failure in V8 WebKit layout tests. If you disagree with the reasoning in the WebKit bug, please ping back so we can fix the WebKit test.
,
Mar 1 2012
,
Mar 1 2012
new RegExp("/").toString() also has different behaviour between V8 and JSC. JSC will return "/\//" where V8 returns "///".
The standard says that RegExp.prototype.toString must return '/' + source + '/', and also states that the result must be a valid RegularExpressionLiteral. These two requirements are clearly contradictory, and JSC seems to be standardizing on the second of the two.
,
Mar 1 2012
Here's another one: var re = new RegExp("\n"). Both JSC and V8 will return a string with a literal newline in it, which 'eval' cannot understand.
,
Mar 1 2012
Erik, toString should use the 'source' property of the regexp object, which Section 15.10.4.1 specifies to be the properly escaped version of the original string. The same paragraph also specifies explicitly that 'source' should be set to "(?:)" if the original string is empty. So no contradiction, we are just wrong.
,
Mar 1 2012
This is related to issue 956 .
,
Mar 1 2012
Issue 956 has been merged into this issue.
,
Mar 1 2012
,
Apr 27 2012
Fixed (for empty RegExp) in r11416. More general escaping still missing, leaving issue open.
,
Jun 29 2015
Another failing case - This is a bug for `new RegExp("\n").toString()` as pointed out in https://github.com/benjamingr/RegExp.escape/issues/30
,
Mar 23 2017
,
Nov 9 2017
,
Jul 6
,
Jul 6
|
||||||
►
Sign in to add a comment |
||||||
Comment 1 by mstarzinger@chromium.org
, Mar 1 2012