Skip to content

fix: handle null positional args before matchers#271

Open
a1573595 wants to merge 1 commit into
felangel:mainfrom
a1573595:cw/256
Open

fix: handle null positional args before matchers#271
a1573595 wants to merge 1 commit into
felangel:mainfrom
a1573595:cw/256

Conversation

@a1573595

Copy link
Copy Markdown

Status

READY

Breaking Changes

NO

Description

Fixes #256.

This fixes positional matcher reconstruction when a real nullable positional argument appears before an argument matcher.

Example:

verify(() => mock.method(null, any()));

Previously, mocktail treated any positional null as a possible matcher placeholder. That caused the real null argument to be consumed as the matcher position, shifting the actual matcher and making verification or capture fail.

The change keeps the existing fallback-value reconstruction model, but removes the blanket null shortcut. Positional matchers are now reconstructed only when the invocation argument matches a stored matcher fallback value. This preserves literal null arguments as real arguments while still supporting any() and captureAny().

Added regression coverage for:

  • verifying null followed by any()
  • capturing an argument after a literal null with captureAny()

Type of Change

  • ✨ New feature (non-breaking change which adds functionality)
  • 🛠️ Bug fix (non-breaking change which fixes an issue)
  • ❌ Breaking change (fix or feature that would cause existing functionality to change)
  • 🧹 Code refactor
  • ✅ Build configuration change
  • 📝 Documentation
  • 🗑️ Chore

@a1573595 a1573595 requested a review from felangel as a code owner May 31, 2026 04:02
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.

Verify positional parameter 'null' not working together with any()

1 participant