You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Interpreter and JIT return different capture counts when a recursion returns the called group #1048
Found while working on #1046. When a recursion returns the called group itself through a capture list, the interpreter and JIT report a different number of captures for the same match:
/(?&r(2))(x)?(?(DEFINE)(?<r>(a)))/
a
/(?&r(2))(x)?(?(DEFINE)(?<r>(a)))/jit
a
pcre2test output (main at 9b338eb, CMake Release build, JIT on, macOS arm64):
/(?&r(2))(x)?(?(DEFINE)(?<r>(a)))/
a
0: a
1: <unset>
2: <unset>
/(?&r(2))(x)?(?(DEFINE)(?<r>(a)))/jit
a
0: a
Here r is group 2 and (a) is group 3, so (?&r(2)) returns the called group. Both engines leave groups 1 and 2 unset, but the interpreter returns 3 (two trailing <unset> groups) while JIT returns 1. Returning group 3 instead ((?&r(3))) gives the same output in both (3: a, with 1 and 2 unset). The same output is produced with #1046 applied. It is not clear to me which return count is intended here, or whether group 2 should be set to a by the return.
Activity