Improve parser error messages to pass more croak.t tests (11→44/330)#273
Merged
Conversation
Error message formatting:
- Rewrite buildNearString() to show forward from error position, stop at
block delimiters ({/}), and preserve trailing whitespace for Perl compat
- Use getSourceLocationAccurate() in throwError for correct #line handling
- Add throwError(int index, String message) overload for precise positioning
- Send compilation errors to stderr instead of stdout in Main.java
Signature validation (SignatureParser.java):
- Add "A slurpy parameter may not have a default value" check
- Add "Mandatory parameter follows optional parameter" check
- Add "Illegal operator following parameter in a subroutine signature" check
- Add "Can't use global $_/@_/%_ in subroutine signature" check
- Fix text: "Named parameters must actually have a name" (matches Perl)
New parser error messages:
- Add "$# is no longer supported as of Perl 5.30" (Variable.java)
- Add "$* is no longer supported as of Perl 5.30" (ParsePrimary.java)
Token position fixes:
- Save firstArgIndex before list parsing for push/unshift errors
- Use paramStartIndex for signature parameter position errors
Generated with [Devin](https://cli.devin.ai/docs)
Co-Authored-By: Devin <noreply@cognition.ai>
The bare $# deprecation check was too aggressive, triggering on valid
uses like $#+ ($#LAST_MATCH_END), $#- ($#LAST_MATCH_START), and
$#{^CAPTURE}. Add +, -, and ^ to the list of valid tokens after $#.
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.
Summary
Improves PerlOnJava's parser error messages to more closely match Perl 5's format, increasing
perl5_t/t/lib/croak.tfrom 11/330 to 44/330 passing tests (4x improvement).Error message formatting (ErrorMessageUtil.java)
buildNearString()to show forward from error position, stop at block delimiters ({/}), and preserve trailing whitespace for Perl compatibilitygetSourceLocationAccurate()inthrowErrorfor correct#linedirective handlingthrowError(int index, String message)overload for precise error position controlSignature validation (SignatureParser.java)
$_/@_/%_in subroutine signature" checkNew parser error messages
$#is no longer supported as of Perl 5.30 (Variable.java)$*is no longer supported as of Perl 5.30 (ParsePrimary.java)Token position fixes
firstArgIndexbefore list parsing for push/unshift errorsparamStartIndexfor signature parameter position errorsTest plan
mvn test)croak.tpasses 44/330 tests (up from 11/330 baseline)Generated with Devin