Perl compatibility fixes: eval caller, mkdir umask, local $our, glob IO#338
Merged
Conversation
t/024WarnDieCarp.t now has 1/73 failures (was 8/73 before caller() fix) Generated with [Devin](https://cli.devin.ai/docs) Co-Authored-By: Devin <noreply@cognition.ai>
When code is inside `eval { BLOCK }`, caller() should report "(eval)"
as the subroutine name. This matches Perl's behavior.
Changes:
- OperatorParser.java: Set subroutine context to "(eval)" before parsing
the eval block, so source locations are saved with correct context
- EmitSubroutine.java: Treat "(eval)" like anonymous subs for closure capture
- ExceptionFormatter.java: Don't add package prefix to special names like "(eval)"
Results:
- Log::Log4perl t/024WarnDieCarp.t: All 73 tests now pass (was 1 failure)
- Total Log4perl: 10/700 failing (was 11/700)
Generated with [Devin](https://cli.devin.ai/docs)
Co-Authored-By: Devin <noreply@cognition.ai>
When local $VarName was used inside a subroutine where $VarName was declared with our in an outer scope, the localization did not work correctly: 1. JVM Backend: EmitOperatorLocal checked if variable was in symbol table and used wrong path (DynamicVariableManager instead of GlobalRuntimeScalar.makeLocal) 2. Interpreter Backend: BytecodeCompiler used cached register for our variables instead of loading from global table Fixes: - EmitOperatorLocal.java: Check for our variables when handling local and use GlobalRuntimeScalar.makeLocal() for them - BytecodeCompiler.java: For scalars/arrays/hashes declared with our, use LOAD_GLOBAL_* instead of cached register This fixes Carp::longmess() with $Carp::CarpLevel, enabling proper stack trace filtering for Log::Log4perl %T format. Generated with [Devin](https://cli.devin.ai/docs) Co-Authored-By: Devin <noreply@cognition.ai>
Log::Log4perl compatibility improved from 10/700 to 8/700 failing subtests. t/022Wrap.t now passes - %T stack trace format works correctly. Generated with [Devin](https://cli.devin.ai/docs) Co-Authored-By: Devin <noreply@cognition.ai>
mkdir() now applies the process umask to the specified mode, matching Perl behavior where effective_mode = mode & ~umask. This fixes Log::Log4perl t/026FileApp.t test 25 which creates directories with mkpath_umask settings. Generated with [Devin](https://cli.devin.ai/docs) Co-Authored-By: Devin <noreply@cognition.ai>
When assigning a glob to a scalar (my $fh = *FH), create a detached copy that shares the current IO slot reference. This ensures that: 1. Captured globs inside a 'local *GLOB' scope retain their IO after the local scope ends (Perl behavior) 2. Multiple file handles from 'local *FH; open FH, ...; return *FH' remain independent and usable Also fix the IO slot save/restore in local to replace the object reference instead of modifying in place. RuntimeStashEntry overrides createDetachedCopy() to return itself, preserving ref() = '' behavior for stash entries. Fixes Log::Log4perl t/026FileApp.t tests 6-7 (file appender with multiple simultaneous log files). Generated with [Devin](https://cli.devin.ai/docs) Co-Authored-By: Devin <noreply@cognition.ai>
ffe3ac0 to
c4bf312
Compare
c4bf312 to
3274514
Compare
When a glob is assigned to a scalar ($_ = *foo), a detached copy is created that shares the same IO slot. Previously, setIO would replace the IO slot entirely, breaking this sharing. Now setIO modifies the slot in place (type and value) to preserve sharing, BUT if the IO slot is tied (TIED_SCALAR with TieHandle), it replaces the slot entirely. This prevents the TiedVariableBase cast error when opening through a PVLV after the original glob was tied. Key fix: setIO(RuntimeIO) now correctly sets type to GLOB (not REFERENCE). Fixes test 188 in uni/gv.t (PVLV: sv_2io stringifieth not). Preserves test 193 (PVLV can be the first arg to open). Restores op/filetest.t and op/postfixderef.t tests. Generated with [Devin](https://cli.devin.ai/docs) Co-Authored-By: Devin <noreply@cognition.ai>
3274514 to
9642674
Compare
fglock
added a commit
that referenced
this pull request
Mar 19, 2026
- 7/700 subtests failing (was 8/700) - Documented mkdir umask fix (PR #338) - Documented local *GLOB semantics fix (PR #338) - Identified tests 6-7 failure as pre-existing multiple file appenders bug - Updated progress tracking with completed items Generated with [Devin](https://cli.devin.ai/docs) Co-Authored-By: Devin <noreply@cognition.ai>
fglock
added a commit
that referenced
this pull request
Mar 19, 2026
* Update log4perl-compatibility.md with latest status - 7/700 subtests failing (was 8/700) - Documented mkdir umask fix (PR #338) - Documented local *GLOB semantics fix (PR #338) - Identified tests 6-7 failure as pre-existing multiple file appenders bug - Updated progress tracking with completed items Generated with [Devin](https://cli.devin.ai/docs) Co-Authored-By: Devin <noreply@cognition.ai> * Update cpan_client.md - symbol table dereference bug is fixed - Symbol table dereference (${ $Pkg::{NAME} }) now works correctly - DateTime still blocked by namespace::autoclean dependency - Updated investigation commands and next steps Generated with [Devin](https://cli.devin.ai/docs) Co-Authored-By: Devin <noreply@cognition.ai> --------- Co-authored-by: Devin <noreply@cognition.ai>
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
Multiple Perl compatibility fixes for Log::Log4perl and glob semantics.
Changes
1. eval block caller() fix
When code is inside
eval { BLOCK },caller()should report(eval)as the subroutine name.2. XS fallback mechanism and DateTime Java implementation
Added support for pure-Java implementations of XS modules.
3. mkdir umask fix
mkdirnow applies the process umask to the mode parameter, matching Perl behavior.4. local $OurVariable fix
Package variables declared with
ournow correctly see localized values.5. local *GLOB semantics fix
Captured file handles (
my $fh = *FH{IO}) now remain valid after the local scope ends.6. Detached glob IO sharing fix
When a glob is assigned to a scalar (
$_ = *foo), the detached copy now correctly shares the IO slot. ThesetIOmethod modifies the slot in place to preserve sharing, but replaces entirely if the slot is tied (to avoid TieHandle cast errors).Key fix:
setIO(RuntimeIO)now correctly sets type toGLOB(notREFERENCE), fixing*GLOB{IO}access.Results
Test Plan
makeGenerated with Devin