Skip to content

mock: Call.Unset(): fix panic #1236#1239

Open
DubbaThony wants to merge 3 commits into
stretchr:masterfrom
DubbaThony:patch-1
Open

mock: Call.Unset(): fix panic #1236#1239
DubbaThony wants to merge 3 commits into
stretchr:masterfrom
DubbaThony:patch-1

Conversation

@DubbaThony
Copy link
Copy Markdown

@DubbaThony DubbaThony commented Jul 27, 2022

Summary

This PR aims to fix #1236. While it's not the pretties fix, it avoids panic

Changes

Within Unset function instead of iterating over an slice and removing items from it at same time, a temporary slice is created, during iteration orginal logic is used to decide if the item should be removed, and if not, item is added to temporary slice.
After iteration temporary slice overrides orginal slice, preventing panic.

Motivation

As library user, I want this function to work.

Related issues

Closes #1236

This PR aims to fix stretchr#1236. While it's not the pretties fix, it avoids panic

Motivation:
As library user, I want this function to work.

Example usage:
n/a

Feature or bug fix?
Bug fix
@DubbaThony DubbaThony changed the title Fix for #1236 Fix for mockCall.Unset() panic (issue #1236) Aug 10, 2022
@dolmen dolmen added bug pkg-mock Any issues related to Mock mock.ArgumentMatcher About matching arguments in mock labels Mar 7, 2024
@dolmen dolmen changed the title Fix for mockCall.Unset() panic (issue #1236) mock: Call.Unset(): fix panic #1236 May 12, 2026
@dolmen dolmen removed the mock.ArgumentMatcher About matching arguments in mock label May 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug pkg-mock Any issues related to Mock

Projects

None yet

Development

Successfully merging this pull request may close these issues.

mock: Call.Unset panics

2 participants