It sure seems like a bug to me.
Yes, I've reached the same conclusion after having played around with this some more.
The issue can be reduced to the following simple test case:
use re 'Debug' => "EXECUTE";
say "xb" =~ /^(?(?!a) (?=bb)).b$/x ? "yes":"no"; # -> yes (wrong
+)
say "xb" =~ /^(?(?!a) (?{}) (?=bb)).b$/x ? "yes":"no"; # -> no (corre
+ct)
The first case incorrectly matches. However, introducing a dummy
eval (?{}) in the second case produces the correct result...
The 'use re 'Debug' => "EXECUTE";' shows the execution
differences (both versions compile to the same code — except for
the eval, obviously):
Guessing start of match in sv for REx "^(?(?!a) (?=bb)).b$" against "x
+b"
Guessed: match at offset 0
Matching REx "^(?(?!a) (?=bb)).b$" against "xb"
0 <> <xb> | 1:BOL(2)
0 <> <xb> | 2:LOGICAL[1](3)
0 <> <xb> | 3:UNLESSM[0](9)
0 <> <xb> | 5: EXACT <a>(7)
failed...
0 <> <xb> | 9:IFTHEN(20)
0 <> <xb> | 11:IFMATCH[0](20)
0 <> <xb> | 13: EXACT <bb>(15)
failed...
0 <> <xb> | 20:REG_ANY(21) <-- incorrectly cont
+inues here
1 <x> <b> | 21:EXACT <b>(23)
2 <xb> <> | 23:EOL(24)
2 <xb> <> | 24:END(0)
Match successful!
yes
Guessing start of match in sv for REx "^(?(?!a) (?{}) (?=bb)).b$" agai
+nst "xb"
Guessed: match at offset 0
Matching REx "^(?(?!a) (?{}) (?=bb)).b$" against "xb"
0 <> <xb> | 1:BOL(2)
0 <> <xb> | 2:LOGICAL[1](3)
0 <> <xb> | 3:UNLESSM[0](9)
0 <> <xb> | 5: EXACT <a>(7)
failed...
0 <> <xb> | 9:IFTHEN(22)
0 <> <xb> | 11:EVAL(13)
0 <> <xb> | 13:IFMATCH[0](22)
0 <> <xb> | 15: EXACT <bb>(17)
failed...
failed...
Match failed
no
|