1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 20:37:35 +00:00

LibRegex: Treat backwards jumps to IP 0 as normal backwards jumps too

This shows up in something like /\d+|x/, where the `+` ends up jumping
to the start of its own alternative.
This commit is contained in:
Ali Mohammad Pur 2023-08-16 19:48:50 +03:30 committed by Ali Mohammad Pur
parent 045880e6c7
commit 4d27257c45
2 changed files with 3 additions and 1 deletions

View file

@ -1150,7 +1150,7 @@ void Optimizer::append_alternation(ByteCode& target, Span<ByteCode> alternatives
VERIFY(node->has_metadata());
QualifiedIP ip = node->metadata_value().first();
auto intended_jump_ip = ip.instruction_position + jump_offset + opcode.size();
if (jump_offset < 0 && intended_jump_ip > 0) {
if (jump_offset < 0) {
VERIFY(has_any_backwards_jump);
// We should've already seen this instruction, so we can just patch it in.
auto& ip_mapping = ip_mapping_for_alternative(ip.alternative_index);