fix: read WHILE_MAX at runtime instead of compile time (GH #149)#396
Open
toddr-bot wants to merge 1 commit intocpan-authors:masterfrom
Open
fix: read WHILE_MAX at runtime instead of compile time (GH #149)#396toddr-bot wants to merge 1 commit intocpan-authors:masterfrom
toddr-bot wants to merge 1 commit intocpan-authors:masterfrom
Conversation
…pan-authors#149) $WHILE_MAX was interpolated as a literal into generated Perl code during template compilation. Changing $Template::Directive::WHILE_MAX after compilation had no effect on cached templates. Now references the package variable so runtime changes take effect immediately. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
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.
What
$WHILE_MAXis now read at runtime in generated WHILE loop code, instead of being baked in as a literal during template compilation.Why
Changing
$Template::Directive::WHILE_MAXafter templates are compiled (or cached) had no effect — the old value was interpolated into the generated Perl code at parse time. This has been reported since 2010 (GH #149, rt.cpan.org #54528).How
Two lines in
Directive::while(): replaced the interpolated$WHILE_MAXwith an escaped\$Template::Directive::WHILE_MAXin the heredoc, so the generated code references the package variable at runtime. Both the failsafe initialization and the error message now use the live value.Testing
t/while_max.t— 4 tests verifying different WHILE_MAX values take effect at runtime (50, 200, 75 in error message, 30 via runtime change).t/while.tpasses unchanged.Closes #149
🤖 Generated with Claude Code