Closed Bug 1650670 Opened 5 years ago Closed 5 years ago

Console instant evaluation updates lastIndex of RegExp as side-effect

Categories

(DevTools :: Console, defect)

79 Branch
defect

Tracking

(Not tracked)

RESOLVED DUPLICATE of bug 1609429

People

(Reporter: lucas.werkmeister, Unassigned)

References

(Blocks 1 open bug)

Details

User Agent: Mozilla/5.0 (X11; Linux x86_64; rv:79.0) Gecko/20100101 Firefox/79.0

Steps to reproduce:

  1. Open any page, e. g. about:blank
  2. Open the Developer Tools Console (Ctrl+Shift+K)
  3. Run const re = /./g;
  4. Run const s = 'abc';
  5. Enter re.exec(s), observe instant evaluation preview
  6. Press Enter to run that command
  7. Type Up arrow to recall that command, observe instant evaluation preview
  8. Press Enter to run that command again

Actual results:

  • First preview is [ "a" ]
  • First actual result is [ "b" ]
  • Second preview is [ "c" ]
  • Second actual result is null

Expected results:

  • First actual result is [ "a" ]
  • Second actual result is [ "b" ]
  • Either the previews should be identical to those results (i. e., evaluate the exec, but then discard the change to re.lastIndex), or Firefox should detect that the command has a side-effect (updating re.lastIndex) and not show any preview.

Bugbug thinks this bug should belong to this component, but please revert this change in case of error.

Component: Untriaged → Console
Product: Firefox → DevTools
Status: UNCONFIRMED → RESOLVED
Closed: 5 years ago
Resolution: --- → DUPLICATE
You need to log in before you can comment on or make changes to this bug.