fix: preserve string portion of $! for unknown error messages#630
Merged
fix: preserve string portion of $! for unknown error messages#630
Conversation
ErrnoVariable.set(String) was discarding the string and storing type=INTEGER, value=0 whenever the input was neither a number nor a known strerror() message. This is the path taken when SystemOperator sets $! from a Java IOException message (e.g. after `system` of a nonexistent program). Result: `my $str = $!` saw 0, not the message, breaking dualvar semantics. Fix: store the unknown-string branch as DUALVAR with a RuntimeScalar(0) numeric side and the message as the string side. Numeric ops still take the fast path through DualVar.numericValue() so they don't go through NumberParser.parseNumber() and won't emit "isn't numeric" warnings, preserving the intent of 7124842. This unblocks PERLANCAR/Proc-ChildError t/01-basics.t, which does system "/tmp/nonexistent"; like(explain_child_error(), qr/^failed to execute: \S.+ \(-1\)/); and in turn unblocks the dependency chain for File::Digest under `./jcpan -t File::Digest` (Proc::ChildError, IPC::System::Options, Perinci::Object, File::Digest itself all pass now). Generated with [Devin](https://cli.devin.ai/docs) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.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.
Summary
Fixes a
$!dualvar bug discovered while running./jcpan -t File::Digest.ErrnoVariable.set(String)was discarding the string and storingtype=INTEGER, value=0whenever the input was neither a number nor a knownstrerror()message. This is the pathSystemOperatortakes when it sets$!from a JavaIOExceptionmessage (e.g. aftersystemof a nonexistent program). As a result,my $str = $!saw0instead of the message, breaking dualvar semantics.Reproducer (before fix)
System Perl correctly returns
[No such file or directory]/TRUE.Fix
Store the unknown-string branch as
DUALVAR(numeric sideRuntimeScalar(0), string side the message), matching the otherset(...)paths in the same file. Numeric ops still take the fast path throughDualVar.numericValue(), so they don't go throughNumberParser.parseNumber()and don't emit "isn't numeric" warnings — preserving the intent of 7124842.Impact
Unblocks
PERLANCAR/Proc-ChildErrort/01-basics.t, which does:This in turn unblocks much of the
File::Digestdependency chain under./jcpan -t File::Digest:Remaining failures in the chain (
JavaScript::QuickJS, parts ofData::Sah::Coerce,Time::Moment) are unrelated XS/native-binding issues.Test plan
makepasses (all unit tests green)./jperl -e 'system "/tmp/nonexistent"; my $str = $!; ...'now matches system Perl's behaviour./jcpan -t Proc::ChildError— Result: PASS./jcpan -t File::Digest— File::Digest itself: Result: PASSGenerated with Devin