Fix glob assignment to correctly alias SCALAR slot for all reference types#361
Merged
Conversation
…types
This fixes two related bugs:
1. Symbolic subroutine reference resolution in wrong package
- &{$hash{key}}() was resolving subroutine names in 'main' package
instead of the current package
- Added isBlockDeref flag to detect &{expr} syntax and call
codeDerefNonStrict for all block-style code dereferences
2. Exporter variable export failing for references
- *glob = \$scalar was incorrectly checking what $scalar contained
and putting it in the wrong slot (ARRAY slot for arrayrefs, etc.)
- Now correctly aliases the SCALAR slot regardless of content
- This fixes Test::Specio and other modules that export variables
containing blessed objects or references
The REFERENCE case in RuntimeGlob.set() was simplified to always alias
the SCALAR slot. Direct \@array and \%hash assignments still work
correctly as they come in as ARRAYREFERENCE/HASHREFERENCE types.
Test results:
- All unit tests pass
- Test::Specio now correctly exports 40/41 variables
- Manual verification of edge cases (blessed objects, code refs, etc.)
Generated with [Devin](https://cli.devin.ai/docs)
Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
8b02a0b to
75ca618
Compare
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
This PR fixes two related bugs involving glob assignments and symbolic references:
Bug 1: Symbolic subroutine reference resolution in wrong package
&{$hash{key}}()was resolving subroutine names in the 'main' package instead of the current package.Before:
After:
Bug 2: Exporter variable export failing for references
*glob = \$scalarwas incorrectly checking what$scalarcontained and putting it in the wrong slot (ARRAY slot for arrayrefs, HASH slot for hashrefs, CODE slot for coderefs).This broke
Exporterwhen exporting variables containing blessed objects or references, affecting modules likeTest::Specio.Before:
After:
Changes
isBlockDerefflag to detect&{expr}syntax and callcodeDerefNonStrictfor all block-style code dereferences when strict refs is disabledTest Plan
make)$UNDEFintentionally undefined)\@arrayand\%hashassignments to globs still work correctlyGenerated with Devin