Fix interpreter parity: list assignment lvalues and special filehandles#308
Merged
Conversation
Simplified list assignment in bytecode compiler to follow the JVM backend
approach: compile the LHS ListNode directly to produce a RuntimeList of
lvalues, then use SET_FROM_LIST.
Now list assignments like ($hash{key}) = @arr work correctly.
Generated with Devin (https://cli.devin.ai/docs)
Co-Authored-By: Devin <noreply@cognition.ai>
The interpreter was incorrectly qualifying special filehandles like STDOUT, STDERR, and STDIN with the current package instead of always using main::. For example, `\*STDOUT` in package Foo was resolving to `Foo::STDOUT` instead of `main::STDOUT`, causing the RuntimeIO to be null and print operations to silently fail. Fixed by using NameNormalizer.normalizeVariableName() which properly handles special variables that must always be in the main package: - BytecodeCompiler: glob (*) variable reference - CompileAssignment: local list assignment This fixes Test::More/Test2 output being silent in interpreter mode. Generated with [Devin](https://cli.devin.ai/docs) 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
This PR fixes two interpreter parity issues:
1. List assignment to hash/array element lvalues
($hash{key}, $array[idx]) = (1, 2)not working in interpreter mode2. Special filehandle resolution (STDOUT/STDERR/STDIN)
\*STDOUTin non-main packages incorrectly resolving toFoo::STDOUTinstead ofmain::STDOUTRoot Cause
The interpreter was manually adding package prefixes instead of using
NameNormalizer.normalizeVariableName()which properly handles special variables that must always be in themain::package.Files Changed
BytecodeCompiler.java- Glob (*) variable referencesCompileAssignment.java- List assignment lvalues and local list assignmentTest Plan
makepassesmvn testpasses (163 tests)make test-interpreterpasses (100% pass rate)./jperl --interpreter src/test/resources/unit/array.tnow produces outputGenerated with Devin