Pod::Simple line accounting drops replacement comments for multi-line POD

Open
#1,441 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
55/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Active
Tech stack
perl
Domain
compilers

Research direction

Start in parse_string_document and related parsing paths, then inspect the callback positions produced for multi-line POD, consecutive POD blocks, blank lines, and code transitions. Add focused tests for code_handler line positions and replacement-line counts, then run t/11_replace_with_comments.t and the Pod::Strip v1.100 suite on both JVM and interpreter backends.

Written by the indexing model from the issue text.

Description

area:cpan-port area:parser bug

Summary

PerlOnJava's bundled Pod::Simple reports incorrect source line positions for multi-line POD blocks. This causes Pod::Strip v1.100 to emit too few replacement comments when replace_with_comments is enabled.

CPAN evidence

  • CPAN run: 20260918-141920-96054
  • Distribution: Pod::Strip v1.100
  • System Perl: PASS — 3 files, 7 tests
  • PerlOnJava: FAIL — 1/3 test programs, 1/7 reported subtests
  • Both JVM and interpreter backends reproduce the failure

The failing test is t/11_replace_with_comments.t. It parses source containing two multi-line POD blocks and expects one # stripped POD comment for each source line removed from the output.

PerlOnJava emits one replacement comment for each POD block. The expected output contains seven comments for the first block and five for the second, while the actual output contains only one for each block.

Root cause

Pod::Strip installs a Pod::Simple code_handler that receives the next source-code line number as its second argument. It uses that line number to emit the appropriate number of # stripped POD lines:

if ($code_line + 1 < $next_code_line) {
    print "# stripped POD\n" x ($next_code_line - $code_line - 1);
}

Under PerlOnJava, the callback line positions do not account for all lines in the removed POD block. The callback therefore believes that the next code line is immediately after the previous code line and emits only one marker per POD section.

This is a Pod::Simple source-position compatibility problem, not a defect in Pod::Strip.

Reproduction

Run the Pod::Strip v1.100 test suite under PerlOnJava. t/00-compile.t and t/10_strip.t pass, while t/11_replace_with_comments.t fails its pod stripped comparison.

A minimal reproducer should parse code containing a multi-line POD block through Pod::Simple with a code_handler, then verify that the callback’s reported line number includes every source line consumed by the POD block.

Expected behavior

For a POD block spanning multiple source lines, Pod::Simple must report the correct next code line to code_handler, matching standard Perl. Consumers that preserve line numbering should then be able to emit one placeholder line per removed source line.

Requested fix

  • Correct Pod::Simple line accounting for multi-line POD sections in parse_string_document and related parsing paths.
  • Preserve accurate callback positions across consecutive POD blocks, blank lines, and transitions between POD and code.
  • Add focused project-owned tests for code_handler line positions and replacement-line counts.
  • Rerun Pod::Strip v1.100 on both JVM and interpreter backends.
Dominant language
Perl
Stars
64
Forks
6
Avg merge
5h 25m
Merged PRs (30d)
157

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from fglock/PerlOnJava

All issues in fglock/PerlOnJava

Similar issues

More Perl issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.