Skip to content

Fix Specio test failures: Unicode properties, B::perlstring, openhandle, eval @_ capture#375

Merged
fglock merged 3 commits into
masterfrom
fix/jcpan-specio-issues
Mar 25, 2026
Merged

Fix Specio test failures: Unicode properties, B::perlstring, openhandle, eval @_ capture#375
fglock merged 3 commits into
masterfrom
fix/jcpan-specio-issues

Conversation

@fglock
Copy link
Copy Markdown
Owner

@fglock fglock commented Mar 25, 2026

Summary

Fixes four issues discovered while running ./jcpan -t Specio:

1. Unicode Is-prefix properties not recognized (UnicodeResolver.java)

  • \P{IsPrint} was matching ALL characters instead of only non-printable ones
  • ICU4J does not recognize Is-prefixed property names (IsPrint, IsDigit, etc.)
  • Fix: Strip Is prefix before ICU lookup (e.g., IsPrint -> Print)

2. B::perlstring not escaping $ and @ (B.pm)

  • Sub::Quote::quote_sub() generates code with hash keys like \$_UNQUOTED
  • Without escaped $, the hash key was interpolated as empty string
  • This caused deferred subs to return undef instead of executing

3. Scalar::Util::openhandle was a placeholder (ScalarUtil.java)

  • Previously always returned false
  • Now properly checks if argument is GLOB/GLOBREFERENCE with open IO handle
  • Fixes FileHandle type detection in Specio

4. @_ not captured in nested blocks for eval-compiled code (InterpretedCode.java, BytecodeInterpreter.java)

  • When code was compiled via eval, the args stack used by List::Util::any/all was not maintained
  • InterpretedCode.apply() bypassed the pushArgs/popArgs calls
  • BytecodeInterpreter's fast path for calling InterpretedCode also bypassed these calls
  • Fixes slurpy Dict type validation in Specio which uses List::Util::all

Test Results

  • Before: 76/311 subtests failed (24.4%)
  • After: 3/311 subtests failed (1.0%)

Remaining 3 failures are pre-existing edge cases:

  • t/parameterized.t (2 tests) - line number tracking differences
  • t/t-clean.t (1 test) - namespace::autoclean can't detect imported vs local subs

Generated with Devin

fglock and others added 3 commits March 25, 2026 13:13
Two bugs were causing Specio test failures:

1. \P{IsPrint} matching all characters (76 test failures)
   - ICU4J doesn't recognize Is-prefixed property names like IsPrint
   - Fixed by stripping 'Is' prefix (e.g., IsPrint -> Print) before ICU lookup
   - The 'Is' prefix is a Perl/Java convention, not an official Unicode property

2. B::perlstring not escaping $ and \@ (caused Sub::Quote failures)
   - quote_sub() generates code like: my $_UNQUOTED = ${...->{"\"}}
   - Without escaped $, the hash key was interpolated as variable
   - This caused deferred subs to return undef instead of executing

Test results improved from 76/311 failed to 6/311 failed.

Generated with [Devin](https://cli.devin.ai/docs)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Previously openhandle was a placeholder always returning false.
Now it properly checks if the argument is a GLOB/GLOBREFERENCE
with an open IO handle (not ClosedIOHandle) and returns the
filehandle itself if open, undef otherwise.

This fixes FileHandle type detection in Specio.

Generated with [Devin](https://cli.devin.ai/docs)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
When code was compiled via eval, the args stack (used by List::Util::any,
all, etc. to pass the outer @_ to code blocks) was not being maintained
correctly.

The issue was that InterpretedCode.apply() overrode RuntimeCode.apply()
but bypassed the pushArgs/popArgs calls that maintain the args stack.
Similarly, BytecodeInterpreter fast path for calling InterpretedCode
also bypassed these calls.

Fixed by:
1. Making RuntimeCode.pushArgs/popArgs public
2. Adding pushArgs/popArgs to InterpretedCode.apply()
3. Adding pushArgs/popArgs to BytecodeInterpreter direct-call fast path

This fixes Specio t/dict.t test which uses slurpy Dict types that
rely on List::Util::all accessing $_[0] from the enclosing scope.

Generated with [Devin](https://cli.devin.ai/docs)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
@fglock fglock changed the title Fix Specio test failures: Unicode properties, B::perlstring, openhandle Fix Specio test failures: Unicode properties, B::perlstring, openhandle, eval @_ capture Mar 25, 2026
@fglock fglock merged commit 994182b into master Mar 25, 2026
2 checks passed
@fglock fglock deleted the fix/jcpan-specio-issues branch March 25, 2026 12:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant