Skip to content

Interpreter: track PC for caller() and honor #line in eval#240

Merged
fglock merged 10 commits into
masterfrom
fix-eval-interpreter-catchup
Feb 26, 2026
Merged

Interpreter: track PC for caller() and honor #line in eval#240
fglock merged 10 commits into
masterfrom
fix-eval-interpreter-catchup

Conversation

@fglock
Copy link
Copy Markdown
Owner

@fglock fglock commented Feb 26, 2026

What\n- Track current bytecode PC during interpreter execution\n- Use pc→tokenIndex mapping (+ ErrorMessageUtil) to report accurate file/line in interpreted stack traces\n- Improve #line handling for interpreted eval so caller() and stack traces are closer to compiled mode\n\n### Why\nInterpreter-mode eval had regressions where caller()/stack traces reported stale line numbers (e.g. base/lex.t ok-count gap).\n\n### Tests\n- make\n- perl5_t/t/base/lex.t (JPERL_EVAL_USE_INTERPRETER=1)

fglock and others added 10 commits February 26, 2026 14:27
….catchEval

Generated with [Devin](https://cli.devin.ai/docs)

Co-Authored-By: Devin <noreply@cognition.ai>
…e mutation bugs

The previous SET_SCALAR-only approach modified the existing RuntimeScalar
object in-place, which corrupted 'local' variable restoration when the
register was shared. The original MOVE approach aliased constants from
the pool, corrupting them on later mutation.

Fix: emit LOAD_UNDEF to allocate a fresh RuntimeScalar, then SET_SCALAR
to copy the value into it. This preserves lvalue semantics while avoiding
both aliasing and in-place mutation issues.

Generated with [Devin](https://cli.devin.ai/docs)

Co-Authored-By: Devin <noreply@cognition.ai>
The LHS of ||/&&// must be SCALAR (for truthiness), but the RHS must
inherit the enclosing context (including RUNTIME) since its value
becomes the result. The previous fix forced SCALAR for both operands,
breaking wantarray propagation through logical operators at sub exit.

Generated with [Devin](https://cli.devin.ai/docs)

Co-Authored-By: Devin <noreply@cognition.ai>
Two fixes for key/value hash slice (%h{...}) in scalar context:

1. Remove top-level ARRAY_SIZE before RETURN in BytecodeCompiler.compile().
   ARRAY_SIZE returns element count for RuntimeList, but eval callers
   already call RuntimeList.scalar() which correctly returns the last
   element. The double conversion produced wrong results for kvhslice.

2. Add LIST_TO_SCALAR conversion in handleHashKeyValueSlice() for scalar
   context, matching the existing pattern in handleArrayKeyValueSlice().

Generated with [Devin](https://cli.devin.ai/docs)

Co-Authored-By: Devin <noreply@cognition.ai>
Add handling for local typeglob assignment (e.g. local *::name = ref)
in the bytecode compiler assignment handler. Emits LOCAL_GLOB to
save/localize the glob, then STORE_GLOB to assign the value.

Generated with [Devin](https://cli.devin.ai/docs)

Co-Authored-By: Devin <noreply@cognition.ai>
@fglock fglock merged commit 3f06893 into master Feb 26, 2026
2 checks passed
@fglock fglock deleted the fix-eval-interpreter-catchup branch February 26, 2026 17:20
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