Repository navigation
fix(fast-check): keep regex flags when generating matching strings - #1721
Open
RaphaelFakhri wants to merge 1 commit into
Open
RaphaelFakhri wants to merge 1 commit into
RaphaelFakhri wants to merge 1 commit into
Conversation
ssalbdivad
added a commit
that referenced
this pull request
Nov 9, 2026
buildStringArbitrary rebuilt each pattern with `new RegExp(rule)`, dropping
its flags. Without u, `\u{1F600}` reads as the text "u{1F600}", so every
string generated for /^\u{1F600}[a-z]$/u failed the type, and a range that
needs u (/^[😀-😂]$/u) threw "Range out of order".
The pattern's flags now reach fc.stringMatching, minus i: fast-check rejects
i, and a string matching without i also matches with it, so dropping it only
narrows what is generated. y and v are passed through so fast-check throws
instead of generating strings the type rejects (dropping y is unsound: /a/y
generated "ba"-shaped strings, 272/300 failing in a probe). \p{...} under u
now throws fast-check's "UnicodeProperty not implemented" instead of
generating the literal "p{Lu}".
Ports #1721 (RaphaelFakhri). Closes #1720.
ssalbdivad
added a commit
that referenced
this pull request
Nov 9, 2026
…uthors Each fix below landed on featherduster from a port or an independent fix, but each started from a reasonable community PR against 2.x, and the CHANGELOG thanks every contributor whose work this release supersedes: - #1721 (@RaphaelFakhri): fast-check keeps a regex's flags (#1720) - #1722 (@louisss1016): Temporal values survive a morph / deepClone (#1719) - #1725 (@RClaudiuM): an undefined discriminant case checks its key (#1724) - #1715 (@SynthLuvr): ~standard.jsonSchema.input drops undefined (#1462); only its input half was taken, output keeps routing to fallback.unit #1718 is not credited: 3.0 answers #1469 with jsonSchema meta rather than its bare pattern key. #1705 and #1695 were already thanked. Also notes that a cyclic index signature with no way out now generates shrinking dictionaries instead of overflowing the stack (6f4dd5d).
Draft
This branch has not been deployed
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.
buildStringArbitraryrebuilt each pattern withnew RegExp(rule), which drops the flags. For a pattern with theuflag, such as/^\u{1F600}[a-z]$/u, the arbitrary generated strings like"u{1F600}a"that fail the type. Ranges that needuthrewSyntaxError: Range out of order.This change passes the pattern's flags to
fc.stringMatching, excepti. fast-check rejectsi, and leaving it out only narrows what gets generated, so every generated string still matches. Flags that fast-check doesn't support (y,v) now make fast-check throw instead of letting the arbitrary generate invalid strings.The new
regex with flagstest fails onmainwith the counterexample"u{1F600}a"and passes with this change.Fixes #1720