@@ -4498,9 +4498,12 @@ codegen_pattern(codegen_scope *s, node *pattern, int target, uint32_t *fail_pos,
|
4498 | 4498 | * 1. Left pattern is not another NODE_PAT_ALT (avoid recursion issues) |
4499 | 4499 | * 2. Left pattern generated at least one JMPNOT |
4500 | 4500 | * 3. The last JMPNOT is immediately before current position |
| 4501 | + * 4. The instruction is actually OP_JMPNOT (not OP_JMP which has |
| 4502 | + * different format S vs BS - converting OP_JMP would corrupt bytecode) |
4501 | 4503 | * In this case, convert JMPNOT to JMPIF and skip generating JMP */ |
4502 | 4504 | if (node_type(pat_alt->left) != NODE_PAT_ALT && |
4503 | | -left_fail != JMPLINK_START && left_fail + 2 == s->pc) { |
| 4505 | +left_fail != JMPLINK_START && left_fail + 2 == s->pc && |
| 4506 | +s->iseq[left_fail - 2] == OP_JMPNOT) { |
4504 | 4507 | /* Extract the previous link from the JMPNOT chain. |
4505 | 4508 | * The chain uses relative offsets where the end is marked by |
4506 | 4509 | * an offset that points to address 0 (i.e., (pos+2)+offset == 0) */ |
|