Skip to content

Fix interpreter eval regressions: bare block, doFile, list assignment validation#235

Merged
fglock merged 1 commit into
masterfrom
fix-interpreter-eval-regressions-2
Feb 25, 2026
Merged

Fix interpreter eval regressions: bare block, doFile, list assignment validation#235
fglock merged 1 commit into
masterfrom
fix-interpreter-eval-regressions-2

Conversation

@fglock
Copy link
Copy Markdown
Owner

@fglock fglock commented Feb 25, 2026

Summary

Fixes regressions when JPERL_EVAL_USE_INTERPRETER=1 is enabled.

Changes

1. Fix For3Node bare block value propagation (BytecodeCompiler.java)

  • { q,bar, }, { q=bar= }, { qq=bar= } in eval STRING crashed with null pointer
  • Root cause: isSimpleBlock path unconditionally set lastResultReg = -1
  • Fix: allocate outer register + MOVE before exitScope, same pattern as BlockNode
  • Fixes: comp/parser.t tests 36, 38, 40

2. Add DO_FILE opcode 340 (Opcodes, CompileOperator, BytecodeInterpreter)

  • do FILE inside eval STRING threw "Unsupported operator: doFile"
  • Added opcode + compiler emit + interpreter handler
  • Fixes: op/do.t (doFile tests)

3. CompileAssignment: validate ListNode LHS with LValueVisitor (CompileAssignment.java)

  • eval q{($a ? $x : ($y)) = 5} silently succeeded instead of setting $@
  • Fix: call LValueVisitor.getContext() on ListNode LHS before compiling assignment
  • Fixes: comp/parser.t test 53

4. Disassembler cases (InterpretedCode.java)

  • Added SET_PACKAGE, PUSH_PACKAGE, POP_PACKAGE, DO_FILE to prevent UNKNOWN(N) output

5. POP_PACKAGE + DO_FILE interpreter handlers (BytecodeInterpreter.java)

  • POP_PACKAGE: no-op (restore handled by existing POP_LOCAL_LEVEL)
  • DO_FILE: calls ModuleOperators.doFile()

Testing

make
cd perl5_t/t
JPERL_EVAL_USE_INTERPRETER=1 ../../jperl comp/parser.t
JPERL_EVAL_USE_INTERPRETER=1 ../../jperl op/do.t

… validation

- For3Node isSimpleBlock: preserve lastResultReg in non-VOID context
  fixes eval '{ q,bar, }', eval '{ q=bar= }', eval '{ qq=bar= }' (comp/parser.t 36,38,40)
- Add DO_FILE opcode (340): compiler emit + interpreter handler + disassembler
  fixes 'do FILE' inside eval STRING (op/do.t)
- CompileAssignment: call LValueVisitor.getContext() on ListNode LHS
  fixes eval q{($a ? $x : ($y)) = 5} error propagation (comp/parser.t 53)
- Add SET_PACKAGE/PUSH_PACKAGE/POP_PACKAGE/DO_FILE disassembler cases
- Add POP_PACKAGE no-op interpreter handler
@fglock fglock merged commit e75ecef into master Feb 25, 2026
2 checks passed
@fglock fglock deleted the fix-interpreter-eval-regressions-2 branch February 25, 2026 13:37
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