fix: support Params::Validate PP backend (glob ref, regex isa, for-loop aliasing)#503
Merged
fix: support Params::Validate PP backend (glob ref, regex isa, for-loop aliasing)#503
Conversation
Document 4 PerlOnJava issues found while testing Params::Validate 1.31: - ref() on GLOB-typed scalars returns slot type instead of "" - RuntimeScalar.createReference() returns REFERENCE instead of GLOBREFERENCE for globs - UNIVERSAL::isa doesn't match "REGEXP" (uppercase) for regex objects - for loop variable aliasing treats literal "0" as truthy Generated with [Devin](https://cli.devin.ai/docs) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
… "0" boolean)
Four fixes to pass the Params::Validate 1.31 PP test suite (2515/2515 subtests):
1. ref() on GLOB-typed RuntimeScalar now returns "" (empty string).
In Perl 5, ref(*glob) always returns "" because bare globs are not
references. Previously PerlOnJava analyzed glob slots and returned
the slot type (e.g. "CODE"), which broke Params::Validate::PP type
detection for glob parameters.
File: ReferenceOperators.java
2. RuntimeScalar.createReference() returns GLOBREFERENCE for GLOB type.
When a glob is wrapped in a RuntimeScalar (after passing through @_
or copy operations), creating a reference via \$val now correctly
produces GLOBREFERENCE instead of REFERENCE. This makes
UNIVERSAL::isa(\*glob, 'GLOB') return true.
File: RuntimeScalar.java
3. UNIVERSAL::isa accepts "REGEXP" (uppercase) for regex objects.
Perl 5 treats both "Regexp" and "REGEXP" as valid class names.
Params::Validate::PP uses the uppercase form in its %isas table.
File: Universal.java
4. RuntimeScalarReadOnly string "0" is now falsy in boolean context.
The constructor pre-computed boolean as !s.isEmpty() but Perl's rule
is that both "" and "0" are false. This broke for-loop variables
aliased to literal "0" (e.g. for my $v (qw(0 1)) { $v ? ... }),
which caused Params::Validate's ignore_case test to select the wrong
expect function.
File: RuntimeScalarReadOnly.java
Generated with [Devin](https://cli.devin.ai/docs)
Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
jcpan -t Params::Validate now works out of the box. The distroprefs automatically pass --pp to Build.PL and set PARAMS_VALIDATE_IMPLEMENTATION=PP, bypassing XS compilation which PerlOnJava cannot perform. 38/38 test programs pass, 2515/2515 subtests (100%). Generated with [Devin](https://cli.devin.ai/docs) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
CPAN::Kwalify loads distroprefs.dd and distroprefs.yml schema files relative to its own module path. These files existed in the source tree but were excluded from the JAR because the build only included *.pm, *.pl, *.ph, and *.pod patterns. This also includes CPAN distroprefs YAML files in the JAR. Fixes: "Could not open 'jar:PERL5LIB/CPAN/Kwalify/distroprefs.dd'" Generated with [Devin](https://cli.devin.ai/docs) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
90e1119 to
7385e79
Compare
The previous createReference() fix for Params::Validate changed \$scalar_holding_glob to produce GLOBREFERENCE type, which stored the RuntimeGlob directly and lost the reference to the RuntimeScalar container. This broke Internals::SvREADONLY on glob copies (-2 in universal.t), open() on \$glob_copy (-1 in open.t), and reading from glob copies (-1 in perlio.t). Fix: revert createReference() to always return REFERENCE type (keeping the RuntimeScalar container accessible). Instead, teach Universal.isa() to recognize that a REFERENCE pointing to a GLOB-typed RuntimeScalar should match "GLOB" (not "SCALAR"). ReferenceOperators.ref() already handled this case correctly (line 135: case GLOB -> "GLOB"). Params::Validate PP test suite still passes 2515/2515. 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
Add full Params::Validate 1.31 pure-Perl support to PerlOnJava. Four runtime fixes ensure the PP test suite passes 100%, and CPAN distroprefs automate the pure-Perl build.
Runtime Fixes
ref()on GLOB: Returns""for bare globs (was incorrectly returning slot type like"CODE")RuntimeScalar.createReference()for GLOB: ReturnsGLOBREFERENCEtype soUNIVERSAL::isa(\*glob, 'GLOB')worksUNIVERSAL::isafor"REGEXP": Accepts uppercase"REGEXP"in addition to"Regexp"RuntimeScalarReadOnlyboolean for"0": String"0"is now correctly falsy (was truthy due to!s.isEmpty()pre-computation)CPAN Distroprefs
Params-Validate.ymlto pass--pptoBuild.PLautomaticallyjcpan -t Params::Validatenow works out of the boxTest Results
makegreen)Test plan
makepasses (no regressions)jcpan -t Params::Validatepasses all 2515 subtestsGenerated with Devin