Skip to content

fix(Scalar-List-Utils): bump bundled modules to v1.70; fix pair*, uniq, get-magic#524

Merged
fglock merged 1 commit intomasterfrom
fix/scalar-list-utils-1.70
Apr 21, 2026
Merged

fix(Scalar-List-Utils): bump bundled modules to v1.70; fix pair*, uniq, get-magic#524
fglock merged 1 commit intomasterfrom
fix/scalar-list-utils-1.70

Conversation

@fglock
Copy link
Copy Markdown
Owner

@fglock fglock commented Apr 21, 2026

Summary

Running ./jcpan -t Scalar::Util (which tests the CPAN Scalar-List-Utils-1.70 distribution against the bundled PerlOnJava implementation) went from:

  • 25/38 test programs failing, 209/832 subtests failing

to:

  • 21/38 test programs failing, 163/842 subtests failing

−46 subtest failures, 4 whole test programs now pass: t/00version.t, t/getmagic-once.t, t/pair.t, t/undefined-block.t.

What changed

Version sync to 1.70

  • Bumped List::Util, Scalar::Util, Sub::Util from the 1.63 stubs to v1.70 (both the .pm files and the $VERSION strings exposed by the Java implementations).
  • List::Util.pm now defines:
    • an import that touches caller's $a/$b (RT #88848, silences spurious "Name used only once" warnings);
    • the List::Util::_Pair class with key / value / TO_JSON methods.

ListUtil.java

  • Validate code-ref arguments for reduce / reductions / first / any / all / none / notall and the pair* family:
    • non-CODE args now croak Not a subroutine reference;
    • calls into undefined stubs croak Undefined subroutine in <func>.
  • pairmap / pairgrep / pairfirst now alias $a and $b in the caller's package to the source list elements (matches Perl 5 XS semantics), so modifications inside the block propagate to the caller.
  • pairgrep / pairmap warn on odd-sized input lists (Odd number of elements in pairmap/pairgrep).
  • pairs() blesses returned arrayrefs into List::Util::_Pair so ->key, ->value, ->TO_JSON work.
  • unpairs() pads short input arrayrefs with undef.
  • uniq distinguishes undef from the empty string; uniq / uniqstr / uniqint / uniqnum now warn on undef with the proper uninitialized-value warning.
  • head / tail croak Not enough arguments for List::Util::head|tail on empty argument lists.

ScalarUtil.java

  • blessed / reftype / refaddr now trigger FETCH on tied scalars exactly once before inspecting the underlying value (fixes t/getmagic-once.t).

Remaining work (not in this PR)

Most of the remaining 163 subtest failures are concentrated in:

  • t/exotic_names.t (120 failures): stash / sub names containing NUL, control characters, or apostrophes. Needs deeper work in set_subname + caller() to preserve embedded NULs in package/sub names.
  • t/subname.t (7): related to the above.
  • BigInt integration in sum / product / min (3+3+1): large integers drop to floats because the operators use double arithmetic.
  • Misc edge cases: overload support in blessed / uniqint / uniqnum, tied filehandle recognition in openhandle, DESTROY tracking in sample / shuffle / uniqstr, taint propagation, weakref edge cases.

Test plan

  • make passes locally (unit tests all green).
  • ./jcpan -t Scalar::Util now reports Failed 21/38 test programs. 163/842 subtests failed, down from 25/38 / 209/832.
  • CI green.

Generated with Devin

Running `./jcpan -t Scalar::Util` against the CPAN Scalar-List-Utils-1.70
distribution went from 25/38 test programs failing (209/832 subtests) to
21/38 (163/842 subtests) — a reduction of 46 subtest failures.

Changes:

* Bump bundled List::Util, Scalar::Util, Sub::Util to v1.70
  (was pinned at 1.63; caused version-mismatch failures because the
  tarball's List/Util/XS.pm reports the distribution version).

* List::Util.pm: add import() that touches caller's $a/$b to silence
  the "Name used only once" warning (RT #88848), and define the
  List::Util::_Pair class methods (key / value / TO_JSON).

* ListUtil.java:
  - Validate code refs for reduce/reductions/first/any/all/none/notall
    and pair*: non-CODE args now croak "Not a subroutine reference";
    calls into undefined stubs croak "Undefined subroutine in <func>"
    (matches XS error messages).
  - pairmap / pairgrep / pairfirst now alias $a and $b to the source
    list elements (matching XS semantics), so modifications inside the
    block are visible to the caller.
  - pairgrep / pairmap warn on odd-sized input lists.
  - pairs() blesses returned arrayrefs into List::Util::_Pair so ->key,
    ->value, ->TO_JSON work.
  - unpairs() pads short input arrayrefs with undef.
  - uniq distinguishes undef from the empty string; uniq/uniqstr/
    uniqint/uniqnum warn on undef with "Use of uninitialized value".
  - head/tail croak "Not enough arguments for List::Util::head|tail"
    when called with no args.

* ScalarUtil.java: blessed / reftype / refaddr now trigger FETCH on
  tied scalars exactly once before inspecting the underlying value
  (fixes t/getmagic-once.t).

Tests that now pass completely:
  t/00version.t, t/getmagic-once.t, t/pair.t, t/undefined-block.t

Remaining failures are mostly in areas requiring deeper work:
  - t/exotic_names.t (120 failures): stash names with NUL / control
    chars / apostrophes — needs set_subname & caller() stash work.
  - t/subname.t (7): related to the above.
  - BigInt integration in sum / product / min (3+3+1).
  - Misc overload / taint / DESTROY tracking edge cases.

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

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
@fglock fglock merged commit aaa6ac0 into master Apr 21, 2026
2 checks passed
@fglock fglock deleted the fix/scalar-list-utils-1.70 branch April 21, 2026 11:12
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