Fix ClassCastException, add Try::Tiny, fix substr and caller/set_subname#349
Merged
Conversation
The bug occurred when: 1. CORE::GLOBAL::require was overridden 2. A file was loaded via do/require 3. That file contained a use statement The parser assumed requireOp.operand was always a ListNode, but it could be a NumberNode (e.g., for version requirements like 'use 5.008'). Added defensive instanceof checks in: - ParsePrimary.java (root cause) - EmitControlFlow.java - EmitOperator.java - EmitRegex.java - CompileOperator.java Generated with [Devin](https://cli.devin.ai/docs) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Try::Tiny: - Pure Perl implementation compatible with Try::Tiny 0.32 - All essential tests pass: basic.t (25/25), finally.t (30/30), context.t (25/25), erroneous_usage.t (8/8) - Supports nested try/catch/finally, multiple finally blocks - Properly re-throws if catch block dies (after finally runs) - Warning format matches original for fatal finally blocks Operator.java (substr): - Fix negative offset behavior to match Perl 5 semantics - Without explicit length: clip negative offsets to 0 (no warning) - With explicit length: warn and return undef if offset is too negative - Fixes unit/warnings.t test Generated with [Devin](https://cli.devin.ai/docs) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
- Add callerWithSub() method that takes __SUB__ parameter - JVM backend now passes __SUB__ to caller() via handleCallerOperator - For caller(0), if __SUB__ has a subName set by set_subname(), use it - Interpreter already worked via InterpreterState tracking code.subName Generated with [Devin](https://cli.devin.ai/docs) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Two fixes for run/switches.t regression introduced in PR #347: 1. Backticks now preserve exact output by reading raw bytes instead of using BufferedReader.readLine() which added extra trailing newlines 2. $^I is now initialized from compilerOptions.inPlaceExtension so the -i switch properly enables in-place editing with backup files Test results: run/switches.t improved from 8/107 to 38/142 (baseline was 29/142) Generated with [Devin](https://cli.devin.ai/docs) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
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
This PR includes several fixes:
1. Fix ClassCastException when CORE::GLOBAL::require is overridden
CORE::GLOBAL::requirereturns a non-RuntimeScalar value2. Add bundled Try::Tiny implementation
src/main/perl/lib/Try/Tiny.pm3. Fix substr negative offset handling
substr("abc", -10)clips to start (no warning)substr("abc", -10, 1)warns and returns undef4. Fix caller() to honor set_subname() for JVM-compiled code
callerWithSub()method that takes__SUB__parameter__SUB__to caller() via newhandleCallerOperator__SUB__has a subName set by set_subname(), use it__SUB__only pushed when caller() is actually usedTest Plan
makepasses (all unit tests)Generated with Devin