Problem
Exhaustive allocation-failure testing of a named-capture expression exposes two parser ownership leaks:
- the normalized name returned by
parseGroupNameis orphaned when parsing or allocating the group body later fails; - non-Unicode
\\d,\\D,\\w, and\\Wnodes duplicate static character-class ranges before allocating the AST node, but do not free that duplicate if node allocation fails.
This was found while making zig-js parse-time RegExp validation use bounded scratch storage in zig-utils/zig-js#560.
Required behavior
- every fallible construction edge rolls back allocations it has not transferred;
- successful AST nodes retain ownership exactly once;
- behavior and accepted RegExp syntax remain unchanged;
- exhaustive
checkAllAllocationFailurescoverage includes a named capture, a lookahead, built-in classes, and ordinary character classes.
Validation
- focused exhaustive allocation-failure test;
- complete zig-regex test suite with zero leaks.
Related: zig-utils/zig-js#560