Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix bug when last argument is a function with multiple return values #774

Merged
merged 2 commits into from Apr 20, 2024

Conversation

LandonTClipp
Copy link
Contributor

@LandonTClipp LandonTClipp commented Apr 20, 2024

Description

There are two bugs fixed in this commit:

  1. As noted in issue Variadic function issues.  #766, mockery failed to generate a mock because it incorrectly considered the return values themselves to be variadic, which is impossible. The fix is to always consider return tuples non-variadic.
  2. The .EXPECT() struct had an incorrect signature when the argument was a variadic function. The reason was because it triggered off the presence of "..." in the type string instead of triggering off the variadic-ness of the outer function. The fix was to simply use the variadic flag to determine if the last argument should be variadic.

Fixes #766

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

Version of Golang used when building/testing:

  • 1.11
  • 1.12
  • 1.13
  • 1.14
  • 1.15
  • 1.16
  • 1.17
  • 1.18
  • 1.19
  • 1.20

There are two bugs fixed in this commit:

1. As noted in issue vektra#766, mockery failed to generate a mock because it incorrectly considered the return values themselves to be variadic, which is impossible. The fix is to always consider return tuples non-variadic.
2. The `.EXPECT()` struct had an incorrect signature when the argument was a variadic function. The reason was because it triggered off the presence of `"..."` in the type string instead of triggering off the variadic-ness of the outer function. The fix was to simply use the `variadic` flag to determine if the last argument should be variadic.
@LandonTClipp LandonTClipp merged commit b1c5f6e into vektra:master Apr 20, 2024
4 checks passed
@LandonTClipp LandonTClipp deleted the issue_766 branch April 20, 2024 05:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Variadic function issues.
1 participant