Interpreter: track PC for caller() and honor #line in eval#240
Merged
Conversation
….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>
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.
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)