mirror of
https://github.com/mruby/mruby
synced 2026-06-08 16:11:16 +00:00
d1aa722a98
The previous optimization for converting JMPNOT+JMP to JMPIF in alternative patterns had two bugs: 1. It triggered incorrectly for nested alternatives like `1 | 2 | 3` (parsed as `((1|2)|3)`), causing memory corruption. 2. The chain end detection was wrong - it checked `prev_offset == 0` but the chain actually ends when `(pos+2) + offset == 0`. Fix by: - Only applying optimization when left pattern is not NODE_PAT_ALT - Correctly detecting chain end by checking if next_addr == 0 - Properly unlinking the last JMPNOT from the fail chain Co-authored-by: Claude <noreply@anthropic.com>