Fix $^H scope leakage and add I18N::Langinfo module#372
Merged
Conversation
The $^H (compile-time hints) variable was using a shared lvalue field to cache values. When Test::More enabled strict mode, the strict bits were cached in lvalue. Later when locale.pm read $^H, it got the stale cached value instead of the current scope's value, causing strict mode to incorrectly leak into outer scopes. Fix: - Remove lvalue caching for HINTS in vivify() - return without storing - Change set() to only update the scope's strict options, not the cache - Change getValueAsScalar() HINTS case to always read from the current scope's symbol table via SpecialBlockParser.getCurrentScope() This ensures $^H respects lexical scoping - each scope has its own value. Generated with [Devin](https://cli.devin.ai/docs) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
- Add I18NLanginfo.java: Java XS implementation with langinfo() function and ~70 locale constants (CODESET, RADIXCHAR, DAY_1-7, MON_1-12, etc.) - Import I18N/Langinfo.pm from Perl 5 distribution - Update constant.pm to full Perl 5 version (was simplified stub) - Add I18N::Langinfo to import config This fixes 07locale.t test (was 1/8, now 8/8 passing). Generated with [Devin](https://cli.devin.ai/docs) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
d781b3e to
67a4521
Compare
Perl's version->parse(undef) and version->parse("undef") both return
version 0. PerlOnJava was throwing "Invalid version format (non-numeric
data)" instead.
This fix is needed for CPAN module testing where ExtUtils::MakeMaker's
MM->parse_version() returns the literal string "undef" for modules
without version numbers (e.g., Dist::CheckConflicts, warnings::register).
Changes:
- Handle RuntimeScalarType.UNDEF by treating as version "0"
- Handle literal string "undef" by treating as version "0"
- Restructure validation to skip when handling undef cases
Fixes DateTime test suite t/00-report-prereqs.t failure.
Generated with [Devin](https://cli.devin.ai/docs)
Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
- PerlLanguageProvider: Propagate $^H (strictOptions) bi-directionally between caller scope and BEGIN block execution scope. This ensures that: 1. BEGIN blocks inherit $^H from the enclosing lexical scope 2. Changes to $^H in BEGIN blocks persist for subsequent code in the same scope - RuntimeRegex: Use Unicode pattern (UNICODE_CHARACTER_CLASS) when the string has the UTF-8 flag set, regardless of whether characters are > 255. This fixes \\w matching Latin-1 characters like è (U+00E8) in UTF-8 strings. - Warnings: Allow warnings::enabled() to be called without arguments (checks if warnings are enabled for the calling package). Required by constant.pm. Test results vs master: - comp/hints.t: 23/31 (was 21/31) - improved by 2 tests - uni/gv.t: 158/206 (same as master) - uni/stash.t: 33/49 (same as master) - op/blocks.t: 9/26 (same as master) Generated with [Devin](https://cli.devin.ai/docs) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Add REGEX case to scalarDeref() to handle dereferencing Regexp objects.
In Perl, ${qr/foo/} returns the stringified form "(?^:foo)".
Previously this threw "Not a SCALAR reference" under strict refs.
Generated with [Devin](https://cli.devin.ai/docs)
Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Revert the Unicode pattern change from commit abba6b9. The change exposed a pre-existing bug where hash keys lose their byte/UTF-8 flag, causing op/utfhash.t to regress from 91/99 to 89/99. Keep the hasUnicodeChars check to avoid the regression. The underlying hash key UTF-8 flag issue is a separate bug to fix later. Generated with [Devin](https://cli.devin.ai/docs) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Add /u modifier to regex patterns for validating constant names. Without this, UTF-8 constant names fail validation because \w does not match Unicode word characters by default. Fixes uni/gv.t and uni/stash.t tests. 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 related fixes discovered during DateTime/I18N::Langinfo testing:
1. Fix
version->parse()to handle undef values (Version.java)Fixes "Invalid version format (non-numeric data)" error when
MM->parse_version()returnsundefor the literal string "undef" for modules without version numbers.2. Fix
$^Hscope leakage (ScalarSpecialVariable.java)Fixes a bug where
use locale(or any module modifying$^H) afteruse Test::Morewas incorrectly enabling strict mode in the outer scope.Problem: The
$^H(compile-time hints) special variable was caching values in a sharedlvaluefield. When Test::More enabled strict mode, the strict bits got cached. Later when locale.pm read$^H, it got the stale cached value.Fix:
lvaluecaching for HINTS invivify()set()to only update the scope's strict options via symbol tablegetValueAsScalar()HINTS case to always read from current scope's symbol table3. Fix
$^Hpropagation between BEGIN blocks (PerlLanguageProvider.java)Fixes
$^Hvalues not persisting between BEGIN blocks in the same lexical scope.Fix: Propagate
$^H(strictOptions) bi-directionally between caller scope and BEGIN block execution scope.4. Add I18N::Langinfo module
langinfo()function and ~70 locale constants5. Fix warnings::enabled() (Warnings.java)
Allow
warnings::enabled()to be called without arguments (checks if warnings are enabled for the calling package). Required by the full Perl 5 constant.pm.6. Fix
${qr//}dereference with strict refs (RuntimeScalar.java)Add REGEX case to
scalarDeref()to handle dereferencing Regexp objects. In Perl,${qr/foo/}returns the stringified form"(?^:foo)". Previously this threw "Not a SCALAR reference" under strict refs.Test plan
$^Hscope leakage case passes:./jperl -e 'use Test::More; use locale; $x = 1; print "OK\n"'$^Hpersists between BEGIN blocks in same lexical scopeuse strictstill correctly enforces variable declarationsuse I18N::Langinfo qw(langinfo CODESET); print langinfo(CODESET)-> UTF-8use utf8; use constant foo => "test"${qr/(?{})/}works with strict refs enabledmake)Generated with Devin