Skip to content

std.regex: document that ctRegex always uses the backtracking engine#11026

Merged
thewilsonator merged 1 commit into
dlang:masterfrom
kubo39:ctregex-backtracking-doc
Jun 7, 2026
Merged

std.regex: document that ctRegex always uses the backtracking engine#11026
thewilsonator merged 1 commit into
dlang:masterfrom
kubo39:ctregex-backtracking-doc

Conversation

@kubo39

@kubo39 kubo39 commented Jun 7, 2026

Copy link
Copy Markdown
Contributor

ctRegex pins CtfeFactory!(BacktrackingMatcher, ...) via withFactory, bypassing the runtime engine auto-selection that picks the Thompson matcher for patterns without backreferences. There is no compile-time code generator for the Thompson engine, so ctRegex matching carries no linear-time guarantee. Document this trade-off so users handling untrusted input can make an informed choice.

ctRegex pins CtfeFactory!(BacktrackingMatcher, ...) via withFactory,
bypassing the runtime engine auto-selection that picks the Thompson
matcher for patterns without backreferences. There is no compile-time
code generator for the Thompson engine, so ctRegex matching carries no
linear-time guarantee. Document this trade-off so users handling
untrusted input can make an informed choice.
@kubo39 kubo39 requested a review from DmitryOlshansky as a code owner June 7, 2026 16:34
@dlang-bot

Copy link
Copy Markdown
Contributor

Thanks for your pull request and interest in making D better, @kubo39! We are looking forward to reviewing it, and you should be hearing from a maintainer soon.
Please verify that your PR follows this checklist:

  • My PR is fully covered with tests (you can see the coverage diff by visiting the details link of the codecov check)
  • My PR is as minimal as possible (smaller, focused PRs are easier to review than big ones)
  • I have provided a detailed rationale explaining my changes
  • New or modified functions have Ddoc comments (with Params: and Returns:)

Please see CONTRIBUTING.md for more information.


If you have addressed all reviews or aren't sure how to proceed, don't hesitate to ping us with a simple comment.

Bugzilla references

Your PR doesn't reference any Bugzilla issue.

If your PR contains non-trivial changes, please reference a Bugzilla issue or create a manual changelog.

Testing this PR locally

If you don't have a local development environment setup, you can use Digger to test this PR:

dub run digger -- build "master + phobos#11026"

@DmitryOlshansky DmitryOlshansky left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, it's fair to warn about the nature of the engine being used.

@thewilsonator thewilsonator merged commit 715a94f into dlang:master Jun 7, 2026
10 checks passed
@kubo39 kubo39 deleted the ctregex-backtracking-doc branch June 7, 2026 22:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants