Commit 9081ee11 authored by erikcorry's avatar erikcorry Committed by Commit bot

RegExp: Fix update of lastIndex on non-global sticky

R=yangguo@chromium.org
BUG=

Review URL: https://codereview.chromium.org/1378693004

Cr-Commit-Position: refs/heads/master@{#31133}
parent 874549c7
...@@ -143,6 +143,10 @@ function RegExpExecNoTests(regexp, string, start) { ...@@ -143,6 +143,10 @@ function RegExpExecNoTests(regexp, string, start) {
var matchInfo = %_RegExpExec(regexp, string, start, RegExpLastMatchInfo); var matchInfo = %_RegExpExec(regexp, string, start, RegExpLastMatchInfo);
if (matchInfo !== null) { if (matchInfo !== null) {
$regexpLastMatchInfoOverride = null; $regexpLastMatchInfoOverride = null;
// ES6 21.2.5.2.2 step 18.
if (FLAG_harmony_regexps && regexp.sticky) {
regexp.lastIndex = matchInfo[CAPTURE1];
}
RETURN_NEW_RESULT_FROM_MATCH_INFO(matchInfo, string); RETURN_NEW_RESULT_FROM_MATCH_INFO(matchInfo, string);
} }
regexp.lastIndex = 0; regexp.lastIndex = 0;
......
...@@ -40,13 +40,13 @@ assertTrue(!!"..foobar".match(plain)); ...@@ -40,13 +40,13 @@ assertTrue(!!"..foobar".match(plain));
var sticky = /foo.bar/y; var sticky = /foo.bar/y;
assertTrue(!!"foo*bar".match(sticky)); assertTrue(!!"foo*bar".match(sticky));
assertEquals(0, sticky.lastIndex); assertEquals(7, sticky.lastIndex);
assertFalse(!!"..foo*bar".match(sticky)); assertFalse(!!"..foo*bar".match(sticky));
var stickyplain = /foobar/y; var stickyplain = /foobar/y;
assertTrue(!!"foobar".match(stickyplain)); assertTrue(!!"foobar".match(stickyplain));
assertEquals(0, stickyplain.lastIndex); assertEquals(6, stickyplain.lastIndex);
assertFalse(!!"..foobar".match(stickyplain)); assertFalse(!!"..foobar".match(stickyplain));
var global = /foo.bar/g; var global = /foo.bar/g;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment