New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Question: Intended semantics for setting lastIndex? #477

Closed
littledan opened this Issue Mar 15, 2016 · 2 comments

Comments

Projects
None yet
4 participants
@littledan
Member

littledan commented Mar 15, 2016

In https://tc39.github.io/ecma262/#sec-regexpbuiltinexec step 12.a.iii, lastIndex is set to 0 regardless of whether sticky or global is true. However, in all other cases, lastIndex is only set when those flags are present. These semantics were a little surprising to me--were they intentional? I'm curious about the history. This came up for me in code review for implementing part of ES2017 semantics for RegExps https://codereview.chromium.org/1776883005 @allenwb @hashseed

@allenwb

This comment has been minimized.

Show comment
Hide comment
@allenwb

allenwb Mar 15, 2016

Member

That's what ES3 and ES 5 did. See:
ES3 15.10.6.2 step 6 and ES5.1 15.10.6.2 step 9.a.i

Member

allenwb commented Mar 15, 2016

That's what ES3 and ES 5 did. See:
ES3 15.10.6.2 step 6 and ES5.1 15.10.6.2 step 9.a.i

@bterlson bterlson added the question label Mar 18, 2016

@domenic

This comment has been minimized.

Show comment
Hide comment
@domenic

domenic Jul 28, 2016

Member

Duping to #625.

Member

domenic commented Jul 28, 2016

Duping to #625.

@domenic domenic closed this Jul 28, 2016

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