assert.Regexp: document allowed rx argument types for Regexp/NotRegexp#1897
Closed
SAY-5 wants to merge 1 commit into
Closed
assert.Regexp: document allowed rx argument types for Regexp/NotRegexp#1897SAY-5 wants to merge 1 commit into
SAY-5 wants to merge 1 commit into
Conversation
…otRegexp Signed-off-by: SAY-5 <say.apm35@gmail.com>
dolmen
requested changes
May 24, 2026
Collaborator
There was a problem hiding this comment.
I think that it is a bug that we accept anything that can be stringified: this leaves to much space to misuse of the API. We should only accept *regexp.Regexp and strict string.
See also Antonboom/testifylint#292
So the last thing I want is to document this as a feature.
We must only document that we accept *regexp.Regexp and string (but unfortunately leave the implementation as is for compatibility).
Collaborator
|
As the example already shows usage with So I'm closing. |
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.
Summary
Document that the rx argument of Regexp/NotRegexp accepts a *regexp.Regexp or any other value.
Changes
go generate ./....Motivation
Requested in #1793 by @brackendawson: "The documentation for these functions should be changed to explain that the value should be a *regexp.Regexp, but that if any other type is provided" it is compiled at runtime. The current doc comments give examples for both forms but never state the accepted types or the panic on an invalid expression.
This is a documentation-only change; the behavior is unchanged.
Related issues
Closes #1793