Skip to content

Fix interpreter eval regressions (JPERL_EVAL_USE_INTERPRETER=1)#233

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

Fix interpreter eval regressions (JPERL_EVAL_USE_INTERPRETER=1)#233
fglock merged 0 commit into
masterfrom
fix-interpreter-eval-regressions

Conversation

@fglock
Copy link
Copy Markdown
Owner

@fglock fglock commented Feb 25, 2026

Summary

Fixes regressions in the bytecode interpreter's eval STRING functionality compared to the JVM compiler. All changes ensure the interpreter produces identical results to the JVM compiler when JPERL_EVAL_USE_INTERPRETER=1 is set.

Fixes

CompileAssignment.java

  • chop/chomp used as lvalues now throw Can't modify chop in scalar assignment (matches JVM compiler)
  • Global scalar assignment ( = 'x') now returns the global variable lvalue (not the rhs copy), so ($_ = 'x') =~ s/// correctly modifies $_ in-place

CompileBinaryOperator.java

  • Added !~ s///r and !~ y///r error checks matching JVM EmitRegex.handleNotBindRegex
  • For =~/!~ in the generic fall-through path, force SCALAR context so CALL_SUB (e.g. use constant quire => qr/.../) emits ctx=SCALAR and returns a scalar

CompileOperator.java

  • Added <> diamond operator support via READLINE opcode routing to DiamondIO
  • replaceRegex/matchRegex bound string (element from =~ binding) compiled in SCALAR context
  • Standalone m// (no =~ binding) now matches against $_ instead of returning the regex object unused

Opcodes.java

  • Added LOAD_VSTRING (337): loads v-string literals with VSTRING type, so require v5.5.640 works in eval STRING
  • Renamed LIST_TO_SCALARLIST_TO_COUNT (count semantics, opcode 60)
  • Added new LIST_TO_SCALAR (338): returns last element (correct Perl list-in-scalar semantics)

BytecodeInterpreter.java

  • Wired up LOAD_VSTRING and new LIST_TO_SCALAR opcodes
  • HASH_KEYS/HASH_VALUES: call .keys()/.values() on RuntimeBase instead of blindly casting to RuntimeHash, so keys undef throws the proper Perl error

OpcodeHandlerExtended.java

  • executeReadline: routes non-glob scalar filehandles to DiamondIO.readline for the <> operator

InterpretedCode.java

  • Disassembler updated for LIST_TO_COUNT, LIST_TO_SCALAR, and LOAD_VSTRING

Tests fixed

  • op/chop.t: 137/137 ✅
  • re/subst.t: 183/183 ✅ (was 182)
  • re/substT.t: 183/183 ✅
  • re/subst_wamp.t: 183/183 ✅
  • op/tr.t: 277/277 ✅
  • op/dor.t: 29/29 ✅
  • op/ver.t: 54/54 ✅
  • op/smartkve.t: 6/6 ✅ (was 4)
  • op/index.t: 414/415 (improved from 413)

@fglock fglock force-pushed the fix-interpreter-eval-regressions branch 2 times, most recently from afeb04a to fde7b02 Compare February 25, 2026 12:52
@fglock fglock merged commit fde7b02 into master Feb 25, 2026
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