Skip to content

Parser rejects valid POD section after executable code #1357

Description

@fglock

Summary

Book::Bilingual v0.003 exposes a PerlOnJava parser bug: a valid POD
directive after executable code is parsed as Perl source. The module's
Book::Bilingual::Reader package fails to compile at =head1 ATTRIBUTES.

CPAN evidence

  • Distribution: Book::Bilingual v0.003
  • CPAN run: 20260910-101908-8428
  • Failure record: FAIL Book::Bilingual::v0.003 Book::Bilingual
  • Failing test: t/60-reader.t
  • PerlOnJava result: 37 earlier tests pass; the Reader test fails before
    running any assertions
  • System Perl result: all 65 tests pass after installing the declared
    Mojolicious and Path::Tiny prerequisites into an isolated library
  • Environment: pure Perl; no XS/native, display, network-service, or
    platform prerequisite is involved

The failure reproduces on both the JVM and interpreter backends.

Minimal reproducer

package Example;

sub answer { 42 }

=encoding utf8
=cut
=head1 ATTRIBUTES
=cut

1;

Standard Perl accepts this file and loads the package. PerlOnJava reports:

syntax error at .../Reader.pm line 290, near "head1 ATTRIBUTES"
Compilation failed in require

CPAN failure details

Book::Bilingual::Reader contains executable code followed by POD beginning
with =encoding utf8, =cut, and =head1 ATTRIBUTES. The first five test
programs pass, while t/60-reader.t requires Book::Bilingual::Reader and
fails during compilation at that POD section. The author-only POD syntax test
is skipped as expected.

System Perl accepts the same source and the complete upstream suite passes.
The same syntax error occurs when loading the Reader module through both
PerlOnJava execution backends, so this is not a backend-specific runtime
failure or an unmet dependency.

Root cause

PerlOnJava's parser does not correctly transition back into POD mode for this
valid directive sequence after code has ended. It treats the head1
directive text as Perl syntax instead of ignoring the POD block until the
next =cut.

This is a PerlOnJava parser compatibility defect, not an error in the
Book::Bilingual distribution.

Expected fix

Recognize valid POD directives after executable code, including =encoding,
=cut, and section directives such as =head1, and exclude their contents
from Perl parsing. Preserve existing handling of POD at other source
locations.

Add permanent project-owned regression coverage for a module containing
executable code followed by this POD sequence. Validate the regression with
system Perl first, then 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:backendJVM interpreter or execution-backend behaviorarea: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