1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 16:18:12 +00:00

LibRegex: Make the optimizer understand references and capture groups

Otherwise the fork in patterns like `(1+)\1` would be (incorrectly)
optimized away.
This commit is contained in:
Ali Mohammad Pur 2021-09-15 14:31:55 +04:30 committed by Ali Mohammad Pur
parent 7de23aede2
commit 741886a4c4
2 changed files with 23 additions and 2 deletions

View file

@ -898,6 +898,10 @@ TEST_CASE(optimizer_atomic_groups)
// Alternative fuse
Tuple { "(abcfoo|abcbar|abcbaz).*x"sv, "abcbarx"sv, true },
Tuple { "(a|a)"sv, "a"sv, true },
// ForkReplace shouldn't be applied where it would change the semantics
Tuple { "(1+)\\1"sv, "11"sv, true },
Tuple { "(1+)1"sv, "11"sv, true },
Tuple { "(1+)0"sv, "10"sv, true },
};
for (auto& test : tests) {