Skip to content

fix: parse Pod below __END__ when __DATA__ section present - #439

Draft
toddr-bot wants to merge 2 commits into
masterfrom
koan.toddr.bot/fix-issue-16
Draft

fix: parse Pod below __END__ when __DATA__ section present#439
toddr-bot wants to merge 2 commits into
masterfrom
koan.toddr.bot/fix-issue-16

Conversation

@toddr-bot

@toddr-bot toddr-bot commented Apr 27, 2026

Copy link
Copy Markdown
Collaborator

Summary

When a __DATA__ section is present, PPI::Token::Data's tokenizer unconditionally consumed all remaining lines — including __END__ and any Pod after it. This fix adds __END__ detection in the Data zone so the tokenizer transitions to the End zone, allowing Pod after __END__ to be properly parsed.

Fixes #16

Changes

  • Add __END__ line detection in PPI::Token::Data::__TOKENIZER__on_line_start that mirrors Word.pm's handling: finalize the Data token, emit a Separator, switch zone to PPI::Token::End
  • Add regression tests covering __DATA__ + __END__ + Pod, including the edge case where __END__ immediately follows __DATA__
  • Round-trip safety preserved (serialize produces identical source)

Test plan

  • New test file t/regression_data_end_pod.t with 12 assertions verifying Pod extraction, Separator count, Data token boundaries, and round-trip fidelity
  • Full test suite passes (70 files, 53,103 tests, zero failures)

Generated by Kōan /fix


Quality Report

Changes: 2 files changed, 85 insertions(+)

Code scan: clean

Tests: skipped

Branch hygiene: clean

Generated by Kōan post-mission quality pipeline

toddr-bot and others added 2 commits April 27, 2026 09:49
#16)

Pod content after __END__ is not recognized when a __DATA__ section
is present earlier in the file. The tokenizer's Data zone consumes
all remaining lines including __END__ and subsequent Pod.

Tests are marked $TODO and will pass once the fix is applied.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…(GH #16)

Data.pm's __TOKENIZER__on_line_start unconditionally consumed all
remaining lines without checking for __END__. This caused __END__
and any Pod after it to be swallowed into the Data token.

Add __END__ detection that mirrors Word.pm's handling: finalize the
Data token, emit a Separator, switch to the End zone, and let
End.pm handle Pod recognition from there.

Remove $TODO markers from the regression tests.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Pod below __END__ not parsed if __DATA__ section is present

2 participants