Skip to content

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

Description

@fglock

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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:cpan-portCPAN compatibility ports and providersarea:parserParsing compilation AST and eval behaviorbugSomething isn't working

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions