Repository navigation
[TS] Support linear RegExp literals in test and match - #535
Merged
Merged
Conversation
CaelmBleidd
force-pushed
the
caelmbleidd/regexp-literal-test-match
branch
from
October 16, 2026 13:51
8df3d31 to
0bfb1cc
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
DateUtils cannot reach its date-math parser because every intrinsic RegExp literal currently stops execution. Add core runtime semantics for a bounded linear subset used by its actual pattern and simpler date-fns token checks. These operations are available with EMPTY and FROZEN model selections and either residual-call policy.
The supported grammar is UTF-16 literals, finite character classes/ranges, ASCII \d/\w, capturing/noncapturing groups, start/end anchors, greedy atom
+, and one optional fixed trailing group. A repeated atom must have a disjoint following atom, so it cannot require backtracking; variable-width patterns require^. Flags, alternation, lookaround, backreferences, unsupported quantifiers, coercion and custom exec remain explicit limitations. The syntax budget is 256 source code units / 64 atoms.Build Bool/ITE terms directly. Each greedy run scans the existing backing bound once; fixed unanchored patterns use a leftmost-match ITE chain. There is no bound-squared start × repetition expansion or interpreted regex loop. Match captures reuse the existing range-copy operation, with a fresh mutable result array, undefined absent captures, and index/input/groups metadata. Without /m,
$requires the absolute end, including rejecting a final newline.Small hooks retain intrinsic regex identity across forks and handle lastIndex/properties without relying on missing structural SDK declarations. A custom test method follows ordinary dispatch; a custom exec callback stops rather than being bypassed. No frontend, SDK, dependency pin or model-catalog changes are needed.
Validation: 16 focused tests passed (7 RegExp test groups and 9 existing runtime-limitation tests), zero skips. They include the real DateUtils pattern with symbolic success/failure/optional captures, all four model/fallback profiles, default backing bound 1000, UTF-16 surrogate units, final LF/CR/CRLF/U+2028/U+2029, leftmost matching, fresh arrays, overrides and unsupported boundaries. Every generated witness in the replay test passes the original source in Node. Restoring the previous literal-allocation limitation makes the DateUtils source regression fail at its unexpected-unsupported-path assertion. CI-style
:usvm-ts:detektMain :usvm-ts:detektTestpassed with zero new findings.This is deliberately partial RegExp support. Complex date-fns parseISO/format expressions, flags and dynamically constructed patterns remain outside it. The full 200-class rerun will measure diagnostic applicability on the combined fixes; these focused checks do not claim full-cohort coverage or performance results.