Skip to content

Restore arity validation after a raising ignore_arity block - #32

Merged
rosston merged 1 commit into
mainfrom
fix-ignore-arity-leak
Oct 12, 2026
Merged

rosston merged 1 commit into
mainfrom
fix-ignore-arity-leak

Conversation

@rosston

@rosston rosston commented Oct 12, 2026

Copy link
Copy Markdown
Member

ValidatesArguments.optional disabled arity validation, ran the demonstration block, then re-enabled it with no ensure. If a stubs(ignore_arity: true) or verify(ignore_arity: true) block raised, validation stayed off for the rest of the fiber, so wrong-arity calls to mocks silently passed until the next Mocktail.reset (or for every later test, in suites that don't reset).

Save the flag's previous value and restore it in an ensure. Restoring the previous value rather than unconditionally enabling also keeps a nested ignore_arity scope from re-enabling validation inside an outer one.

The new blk.call line shifts the line numbers that Debug's internal mock-call guard allow-lists for validates_arguments.rb, so update them (untyped lib build, then src).

ValidatesArguments.optional disabled arity validation, ran the
demonstration block, then re-enabled it with no `ensure`. If a
`stubs(ignore_arity: true)` or `verify(ignore_arity: true)` block
raised, validation stayed off for the rest of the fiber, so
wrong-arity calls to mocks silently passed until the next
Mocktail.reset (or for every later test, in suites that don't reset).

Save the flag's previous value and restore it in an `ensure`. Restoring
the previous value rather than unconditionally enabling also keeps a
nested ignore_arity scope from re-enabling validation inside an outer
one.

The new `blk.call` line shifts the line numbers that Debug's internal
mock-call guard allow-lists for validates_arguments.rb, so update them
(untyped lib build, then src).
@rosston rosston self-assigned this Oct 12, 2026
@rosston
rosston marked this pull request as ready for review October 12, 2026 13:43
@rosston
rosston merged commit 89c8917 into main Oct 12, 2026
10 checks passed
@rosston
rosston deleted the fix-ignore-arity-leak branch October 12, 2026 13:44
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.

1 participant