Skip to content

Fix interpreter parity: list assignment lvalues and special filehandles#308

Merged
fglock merged 2 commits into
masterfrom
fix/list-assignment-lvalues
Mar 13, 2026
Merged

Fix interpreter parity: list assignment lvalues and special filehandles#308
fglock merged 2 commits into
masterfrom
fix/list-assignment-lvalues

Conversation

@fglock
Copy link
Copy Markdown
Owner

@fglock fglock commented Mar 13, 2026

Summary

This PR fixes two interpreter parity issues:

1. List assignment to hash/array element lvalues

  • Fixed ($hash{key}, $array[idx]) = (1, 2) not working in interpreter mode

2. Special filehandle resolution (STDOUT/STDERR/STDIN)

  • Fixed \*STDOUT in non-main packages incorrectly resolving to Foo::STDOUT instead of main::STDOUT
  • This caused Test::More/Test2 output to be silent in interpreter mode

Root Cause

The interpreter was manually adding package prefixes instead of using NameNormalizer.normalizeVariableName() which properly handles special variables that must always be in the main:: package.

Files Changed

  • BytecodeCompiler.java - Glob (*) variable references
  • CompileAssignment.java - List assignment lvalues and local list assignment

Test Plan

  • make passes
  • mvn test passes (163 tests)
  • make test-interpreter passes (100% pass rate)
  • ./jperl --interpreter src/test/resources/unit/array.t now produces output

Generated with Devin

fglock and others added 2 commits March 13, 2026 14:38
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>
@fglock fglock merged commit 92629c4 into master Mar 13, 2026
2 checks passed
@fglock fglock deleted the fix/list-assignment-lvalues branch March 13, 2026 14:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant