Bug 260928 - [Yarr] Yarr JIT returns a nested capture when an outer paren matches a zero length string
Summary: [Yarr] Yarr JIT returns a nested capture when an outer paren matches a zero l...
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: JavaScriptCore (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Michael Saboff
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2023-08-30 15:38 PDT by Michael Saboff
Modified: 2023-08-30 23:03 PDT (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Michael Saboff 2023-08-30 15:38:05 PDT
Consider the RegExp /(?:(?=(abc)))?a/.  The lookahead assertion contains a captured sub pattern of "abc".  The outer group is quantified with the '?' suffix, which means it can match 0 or 1 times.  When this RegExp is used to match the string "abc", the assertion will match the "abc" and that sub pattern will be captured.  The ECMAScript spec in [RepeastMatcher](https://tc39.es/ecma262/#sec-runtime-semantics-repeatmatcher-abstract-operation) for the case where the minimum match quantity is 0.  See step 2.b. in the spec link.

The Yarr interpreter matches as the spec requires, returning the capture only if the quantifier has a minimum of 1.  The Yarr JIT however always returns the nested capture, irrespective of the quantifier for the outer paren.  Therefore the JIT needs to be fix to match the spec and the interpreter.
Comment 1 Michael Saboff 2023-08-30 15:38:18 PDT
<rdar://106376813>
Comment 2 Michael Saboff 2023-08-30 15:51:37 PDT
Pull request: https://github.com/WebKit/WebKit/pull/17254
Comment 3 EWS 2023-08-30 23:03:08 PDT
Committed 267486@main (e5b0472ba9a2): <https://commits.webkit.org/267486@main>

Reviewed commits have been landed. Closing PR #17254 and removing active labels.