Repository navigation
mock: compare options after matching zero-argument functions - #1983
Open
sergioperezcheco wants to merge 1 commit into
Open
sergioperezcheco wants to merge 1 commit into
sergioperezcheco wants to merge 1 commit into
Conversation
Signed-off-by: sergioperezcheco <checo520@outlook.com>
otrumb
approved these changes
Oct 5, 2026
otrumb
left a comment
There was a problem hiding this comment.
Verified at c41bc9ec0f23fce21d29360c252a243ce3e1044c. The one-line return to continue change fixes later-position identity matching for zero-argument functional options while preserving non-invocation and ordinary functional-option semantics. Base reproduction failed for second/third-position mismatches; exact head passed independent public-surface tests, the added regression 20 times, focused and full tests, vet, and CGO-disabled build. No blocking or warning findings.
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
Fix functional-option matching stopping after the first matching zero-argument function.
Changes
mock.Arguments.DiffandAssertregressions for mismatches in the second and third positions, with equal, first-mismatch, length and empty controls.Motivation
assertOptsexplicitly handles zero-argument functions without invoking them. However, returning after the first matching function bypasses the source-identity checks for all later functions. For example, an expectation containingFunctionalOptions(optionA, optionA)incorrectly matches[]func(){optionA, optionB}whenoptionAandoptionBare distinct zero-argument functions defined on different lines.This is a bug fix within that existing zero-argument branch, not a change to the ordinary
func(*Config)option pattern. It preserves the source-file/line identity rule and does not invoke zero-argument functions or expand the API.On the unchanged base commit, the second- and third-position regressions fail through both
DiffandAssert; the four controls pass. With this change, the full mock package race tests, mock vet and targeted incremental govet/staticcheck lint pass locally. Those results were obtained on the identical base and exact same production/test bytes and reused for this commit. Formatting andgit diff --checkalso pass. The full repository, generation step, other Go versions, other operating systems and remote CI have not been run.Related issues
No existing issue was found for this early-return case. #1023 introduced the zero-argument handling; #1626 established the current per-function source-identity comparison. This does not reopen their original functional-option or indirect-call requests, nor implement the #1578 matcher API refactor.
Implemented by Hermes Agent (Nous Research), using model
gpt-6.1-sol. No human-review claim is made.