Skip to content
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

feat: add sutiable RegExp prototype methods #4737

Merged
merged 1 commit into from Dec 8, 2022

Conversation

TrickyPi
Copy link
Member

@TrickyPi TrickyPi commented Dec 6, 2022

This PR contains:

  • bugfix
  • feature
  • refactor
  • documentation
  • other

Are tests included?

  • yes (bugfixes and features will not be merged without tests)
  • no

Breaking Changes?

  • yes (breaking changes will not be merged unless absolutely necessary)
  • no

List any relevant issue numbers:

resolves #4694

Description

declare suitable RegExp prototype methods as side effect free.

@codecov
Copy link

codecov bot commented Dec 6, 2022

Codecov Report

Merging #4737 (64c3a5a) into master (248d09a) will increase coverage by 0.00%.
The diff coverage is 100.00%.

@@           Coverage Diff           @@
##           master    #4737   +/-   ##
=======================================
  Coverage   99.03%   99.03%           
=======================================
  Files         217      217           
  Lines        7698     7701    +3     
  Branches     2128     2129    +1     
=======================================
+ Hits         7624     7627    +3     
  Misses         24       24           
  Partials       50       50           
Impacted Files Coverage Δ
src/ast/values.ts 100.00% <100.00%> (ø)

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

@github-actions
Copy link

github-actions bot commented Dec 8, 2022

Thank you for your contribution! ❤️

You can try out this pull request locally by installing Rollup via

npm install TrickyPi/rollup#feat/add-RegExp-free-logical

or load it into the REPL:
https://rollupjs.org/repl/?pr=4737

Copy link
Member

@lukastaegert lukastaegert left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great!

@lukastaegert lukastaegert merged commit e83d539 into rollup:master Dec 8, 2022
@rollup-bot
Copy link
Collaborator

This PR has been released as part of rollup@3.7.0. You can test it via npm install rollup.

@TrickyPi TrickyPi deleted the feat/add-RegExp-free-logical branch December 8, 2022 07:08
@syranide
Copy link

syranide commented Dec 8, 2022

They aren't always side-effect free though?

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/exec

JavaScript RegExp objects are stateful when they have the global or sticky flags set (e.g. /foo/g or /foo/y). They store a lastIndex from the previous match.

Or is "this kind of" side-effect not applicable here for other reasons?

@TrickyPi
Copy link
Member Author

TrickyPi commented Dec 8, 2022

Oh, thank you so much for your spotting. Maybe we should check the RegExp is global or sticky.

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

Successfully merging this pull request may close these issues.

the unused var not be removed
4 participants