Fix eval interpreter catchup: 11 bytecode compiler/interpreter fixes#241
Merged
Conversation
… strict scoping, non-local control flow, undefined sub errors - CompileOperator: compile unaryMinus operand in scalar context to avoid ClassCastException when negating parenthesized expressions in list context - ErrorMessageUtil: use originalFileName in getSourceLocationAccurate() so #line directives do not retroactively change filename for earlier tokens - BytecodeCompiler: push/pop strict/feature/warning flags in enterScope/exitScope so use strict inside blocks is properly scoped - BytecodeCompiler: emit CREATE_LAST/NEXT/REDO + RETURN for non-local loop control instead of throwing compile-time error (enables last/next/redo across eval boundaries) - RuntimeCode: construct subroutine name from code.packageName/subName when subroutineName is empty, fixing Not a CODE reference vs Undefined subroutine error messages Generated with [Devin](https://cli.devin.ai/docs) Co-Authored-By: Devin <noreply@cognition.ai>
RuntimeGlob.dynamicSaveState/RestoreState now saves and restores the actual globalVariables/globalArrays/globalHashes/globalCodeRefs map entries in addition to calling dynamicSaveState on the slot objects. This fixes local *glob = \"ref" where aliasGlobalVariable replaces the map entry: on restore the original entry is put back before its state is restored, preventing the shared static dynamicStateStack from corrupting the aliased object. Fixes uni/gv.t test 169 regression in interpreter mode. Generated with [Devin](https://cli.devin.ai/docs) Co-Authored-By: Devin <noreply@cognition.ai>
380c654 to
dd43cc7
Compare
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.
Summary
Batch of fixes to close the gap between JVM-compiled and bytecode-interpreter execution paths for
eval STRING(JPERL_EVAL_USE_INTERPRETER=1).Fixes in this PR
caller()and stack traces now report correct file/line inside eval strings, honoring#linedirectives$SIG{__DIE__}in eval — exception handling routes throughWarnDie.catchEvalSET_SCALARto preserve lvalue semantics, avoids aliasing bugs...) expression context — parser now correctly errors on expression-context usagelocal *glob = value— bytecode compiler supports local glob assignmentLIST_TO_SCALARopcode returns last element instead of countwantarray— RHS of\|\|/&&///inherits enclosing context-(42)#linedirective tracking —getSourceLocationAccurate()uses original filename so directives don't retroactively change earlier tokensenterScope()/exitScope()now push/pop pragma stacks so{use strict;}is properly block-scopedlast/next/redo LABELacross eval boundaries emitsCREATE_LAST + RETURNinstead of compile-time errorTest plan
./gradlew classes testUnitParallel --parallel shadowJarpassesbase/lex.t,comp/parser.t,comp/use.t,uni/caller.t,uni/labels.top/wantarray.t,op/kvhslice.t,comp/fold.t,op/signatures.tuni/gv.t(test 169 diff is pre-existing false positive)Generated with Devin