Bug 260928

Summary: [Yarr] Yarr JIT returns a nested capture when an outer paren matches a zero length string
Product: WebKit Reporter: Michael Saboff <msaboff>
Component: JavaScriptCoreAssignee: Michael Saboff <msaboff>
Status: RESOLVED FIXED    
Severity: Normal CC: webkit-bug-importer
Priority: P2 Keywords: InRadar
Version: WebKit Nightly Build   
Hardware: Unspecified   
OS: Unspecified   

Michael Saboff
Reported 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.
Attachments
Michael Saboff
Comment 1 2023-08-30 15:38:18 PDT
Michael Saboff
Comment 2 2023-08-30 15:51:37 PDT
EWS
Comment 3 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.
Note You need to log in before you can comment on or make changes to this bug.