fix: auto-set errno for int ops returning CHECK_IS_FALSE#79
Draft
Koan-Bot wants to merge 1 commit intocpan-authors:mainfrom
Draft
fix: auto-set errno for int ops returning CHECK_IS_FALSE#79Koan-Bot wants to merge 1 commit intocpan-authors:mainfrom
Koan-Bot wants to merge 1 commit intocpan-authors:mainfrom
Conversation
When a mock for -s/-M/-A/-C returned CHECK_IS_FALSE (0) without setting $!, the $OP_CAN_RETURN_INT fast-path returned immediately, bypassing the auto-errno logic that boolean ops get. This left $! at zero (or stale), creating an observable inconsistency: returning undef auto-set ENOENT but returning CHECK_IS_FALSE did not. Add the same !int($!) guard to the int-op fast-path so falsy returns consistently get a default errno when the callback didn't set one. Closes cpan-authors#62 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
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.
What
Make
_check()auto-set a default errno when int ops (-s,-M,-A,-C) returnCHECK_IS_FALSEwithout the callback having set$!.Why
The
$OP_CAN_RETURN_INTfast-path returned immediately for any defined value, bypassing the auto-errno logic that boolean ops get. This meant returningundefauto-set ENOENT (via CHECK_IS_NULL), but returningCHECK_IS_FALSEleft$!at 0 or stale — an observable inconsistency that confuses users checking$!after mocked file tests.How
Added the same
!int($!)guard to the int-op fast-path: when the return is falsy and the callback didn't set errno, apply the default errno (ENOENT for most ops, ENOEXEC for -x/-X).Testing
t/int-errno-preservation.tcovering the exact scenario:-smock returnsCHECK_IS_FALSEwithout setting$!, verifies ENOENT is auto-setCloses #62
🤖 Generated with Claude Code