feat(engine): make String.prototype.repeat respect loop iteration limit#5069
Conversation
Test262 conformance changes
Tested main commit: |
|
Hi @jedel1043, CI checks have passed for this PR. When you have some time, I’d appreciate a review. This change focuses on the minimal entry point mentioned in the issue |
|
|
||
| std::iter::repeat_n(string.as_str(), n).for_each(|s| result.push(s)); | ||
| // Charge each repetition against the VM loop-iteration limit. | ||
| let mut result = Vec::new(); |
There was a problem hiding this comment.
You forgot to carry over the with_capacity
There was a problem hiding this comment.
I’ve restored Vec::with_capacity(n) in the latest commit.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #5069 +/- ##
===========================================
+ Coverage 47.24% 59.09% +11.85%
===========================================
Files 476 563 +87
Lines 46892 62574 +15682
===========================================
+ Hits 22154 36981 +14827
- Misses 24738 25593 +855 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
This Pull Request fixes/closes #5060.
It changes the following:
Context::set_loop_iteration_limitIncrementLoopIteration::operation((), context)insideString.prototype.repeatso large repeat counts consume the VM loop budget and throwRuntimeLimitError::LoopIterationwhen the limit is exceededString.prototype.repeatthrow the sameRuntimeLimitError::LoopIterationTesting:
cargo test -p boa_engine(including the new runtime-limit tests for built-in iteration)