Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Do not treat string.replace as side effect when used with a literal (#…
…4494) * Do not make Object.defineProperty/ies a side effect by default * Detect side effects for getters on functions * Less deoptimization for non-accessor assignments * Use ObjectEntity for arrow function properties * Share code between functions and arrow functions * Use new path key for defineProperty side effects * Enable custom call-effect detection per global * Improve coverage * Do not treat string.replace as side effect when used with a literal * Remove unneeded prop
- Loading branch information
1 parent
bbd54b7
commit 4079fbe
Showing
4 changed files
with
64 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
module.exports = { | ||
description: | ||
'does not assume string.replace has side effects when called with a string as second argument' | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
'foo'.replace('o', () => { | ||
console.log('retained'); | ||
return '_'; | ||
}); | ||
'foo'.replaceAll('o', () => { | ||
console.log('retained'); | ||
return '_'; | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
'foo'.replace('o', 'removed'); | ||
'foo'.replace('o', () => 'removed'); | ||
'foo'.replace('o', () => { | ||
console.log('retained'); | ||
return '_'; | ||
}); | ||
|
||
'foo'.replaceAll('o', 'removed'); | ||
'foo'.replaceAll('o', () => 'removed'); | ||
'foo'.replaceAll('o', () => { | ||
console.log('retained'); | ||
return '_'; | ||
}); |