Fix HEREDOC parsing inside BEGIN blocks (#366)#367
Merged
Conversation
f9439a4 to
c8049e1
Compare
When a HEREDOC is declared inside a BEGIN block (e.g., `BEGIN { eval <<'END' }`),
the heredoc content appears on subsequent lines after the block closes. However,
BEGIN blocks execute immediately during parsing, before the newline that triggers
heredoc content processing.
The fix processes any pending heredocs before executing BEGIN blocks:
1. After parsing the closing `}` of a BEGIN block, check for pending heredocs
2. If found, temporarily advance to the next NEWLINE and process heredocs
3. Store the post-heredoc position for later skip
4. Restore tokenIndex to continue normal parsing
5. When later encountering the NEWLINE in normal parsing, skip past the
already-processed heredoc content
This enables CPAN::Meta::YAML and other modules that use this pattern.
Generated with [Devin](https://cli.devin.ai/docs)
Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
c8049e1 to
1bee908
Compare
The -t file test operator now correctly checks if standard streams are connected to a terminal using POSIX isatty(). Previously, -t STDIN always returned undef/false, causing programs like cpanm to incorrectly try to read module names from STDIN when run interactively. This fixes cpanm hanging in interactive terminals when STDIN is actually a TTY but -t STDIN was returning false. Generated with [Devin](https://cli.devin.ai/docs) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
The CycloneDX plugin outputs warnings about unknown JSON schema keywords (meta:enum, deprecated) which are harmless but noisy. Redirect the task stdout/stderr to INFO level to suppress these warnings during normal builds. Generated with [Devin](https://cli.devin.ai/docs) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
188e4b7 to
a7d555a
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #366 - HEREDOC parsing now works correctly inside BEGIN blocks.
When a HEREDOC is declared inside a BEGIN block (e.g.,
BEGIN { eval <<'END' }), the heredoc content appears on subsequent lines after the block closes. However, BEGIN blocks execute immediately during parsing, before the newline that triggers heredoc content processing.Changes
heredocSkipToIndexfield to track where to skip after pre-processed heredocsheredocSkipToIndexset, skip past already-processed heredoc contentTest Plan
Impact
This enables
cpanmand other tools that loadCPAN::Meta::YAML, which uses this pattern for optional dependency loading.Generated with Devin