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

Add regexp indices (d flag) support #3094

Merged
merged 3 commits into from
Jul 9, 2023

Conversation

dirkdev98
Copy link
Contributor

@dirkdev98 dirkdev98 commented Jul 1, 2023

This Pull Request closes #3086

It changes the following:

  • Implements re.exec().indices & re.exec().indices.groups
  • Fixes ordering of re.exec().groups to pass strict test262 tests
  • Updates related comments to be inline with the spec
  • Skipped the two unicode related tests in the test/built-ins/RegExp/match-indices suite. Which seems to be a separate task in itself across the Regex implementation.

I'm a bit unsure about the following:

@dirkdev98
Copy link
Contributor Author

dirkdev98 commented Jul 1, 2023

Test262 conformance changes

Test result main count PR count difference
Total 94,842 94,842 0
Passed 74,691 74,717 +26
Ignored 18,812 18,812 0
Failed 1,339 1,313 -26
Panics 0 0 0
Conformance 78.75% 78.78% +0.03%
Fixed tests (26):
test/built-ins/RegExp/match-indices/indices-array-unmatched.js [strict mode] (previously Failed)
test/built-ins/RegExp/match-indices/indices-array-unmatched.js (previously Failed)
test/built-ins/RegExp/match-indices/indices-property.js [strict mode] (previously Failed)
test/built-ins/RegExp/match-indices/indices-property.js (previously Failed)
test/built-ins/RegExp/match-indices/indices-array.js [strict mode] (previously Failed)
test/built-ins/RegExp/match-indices/indices-array.js (previously Failed)
test/built-ins/RegExp/match-indices/indices-array-element.js [strict mode] (previously Failed)
test/built-ins/RegExp/match-indices/indices-array-element.js (previously Failed)
test/built-ins/RegExp/match-indices/indices-groups-object.js [strict mode] (previously Failed)
test/built-ins/RegExp/match-indices/indices-groups-object.js (previously Failed)
test/built-ins/RegExp/match-indices/indices-array-matched.js [strict mode] (previously Failed)
test/built-ins/RegExp/match-indices/indices-array-matched.js (previously Failed)
test/built-ins/RegExp/match-indices/indices-groups-properties.js [strict mode] (previously Failed)
test/built-ins/RegExp/match-indices/indices-groups-properties.js (previously Failed)
test/built-ins/RegExp/match-indices/indices-array-unicode-property-names.js [strict mode] (previously Failed)
test/built-ins/RegExp/match-indices/indices-array-unicode-property-names.js (previously Failed)
test/built-ins/RegExp/match-indices/indices-groups-object-unmatched.js [strict mode] (previously Failed)
test/built-ins/RegExp/match-indices/indices-groups-object-unmatched.js (previously Failed)
test/built-ins/RegExp/match-indices/indices-groups-object-undefined.js [strict mode] (previously Failed)
test/built-ins/RegExp/match-indices/indices-groups-object-undefined.js (previously Failed)
test/built-ins/RegExp/match-indices/indices-array-properties.js [strict mode] (previously Failed)
test/built-ins/RegExp/match-indices/indices-array-properties.js (previously Failed)
test/built-ins/RegExp/named-groups/groups-properties.js [strict mode] (previously Failed)
test/built-ins/RegExp/named-groups/groups-properties.js (previously Failed)
test/built-ins/RegExp/named-groups/lookbehind.js [strict mode] (previously Failed)
test/built-ins/RegExp/named-groups/lookbehind.js (previously Failed)

@codecov
Copy link

codecov bot commented Jul 1, 2023

Codecov Report

Merging #3094 (9616a00) into main (a9a2e1b) will decrease coverage by 0.02%.
The diff coverage is 52.94%.

@@            Coverage Diff             @@
##             main    #3094      +/-   ##
==========================================
- Coverage   50.42%   50.40%   -0.02%     
==========================================
  Files         444      444              
  Lines       45877    45921      +44     
==========================================
+ Hits        23132    23145      +13     
- Misses      22745    22776      +31     
Impacted Files Coverage Δ
boa_engine/src/builtins/regexp/mod.rs 61.33% <52.94%> (-2.12%) ⬇️

Copy link
Member

@HalidOdat HalidOdat left a comment

Choose a reason for hiding this comment

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

Looks good! nice work! :)

@HalidOdat HalidOdat added enhancement New feature or request builtins PRs and Issues related to builtins/intrinsics labels Jul 2, 2023
@HalidOdat
Copy link
Member

GetMatchIndexPair and MakeMatchIndicesIndexPairArray are currently done inline. This complicates the comments quite a bit, but not sure if it's worth it to extract them (partially).

About this, GetMatchIndexPair only seems to be used in MakeMatchIndicesIndexPairArray and MakeMatchIndicesIndexPairArray only seems to be used in RegExpBuiltinExec ( R, S )`, I think it's fine to leave it inlined :)

@dirkdev98
Copy link
Contributor Author

Something goes wrong locally for me when running test262 which causes the unrelated failures (see #3111). Updated the test262 comment with the latest CI run (https://github.com/boa-dev/boa/actions/runs/5431555600/jobs/9877999206#step:10:104)

Copy link
Member

@jedel1043 jedel1043 left a comment

Choose a reason for hiding this comment

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

Nice addition!

@jedel1043 jedel1043 added this pull request to the merge queue Jul 9, 2023
@jedel1043 jedel1043 added this to the v0.18.0 milestone Jul 9, 2023
Merged via the queue into boa-dev:main with commit 1a2be79 Jul 9, 2023
@dirkdev98 dirkdev98 deleted the feat/re-indices branch July 9, 2023 20:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
builtins PRs and Issues related to builtins/intrinsics enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Implement RegExp d flag
3 participants