Skip to content

fix: read WHILE_MAX at runtime instead of compile time (GH #149)#396

Open
toddr-bot wants to merge 1 commit intocpan-authors:masterfrom
toddr-bot:koan.toddr.bot/fix-while-max-runtime
Open

fix: read WHILE_MAX at runtime instead of compile time (GH #149)#396
toddr-bot wants to merge 1 commit intocpan-authors:masterfrom
toddr-bot:koan.toddr.bot/fix-while-max-runtime

Conversation

@toddr-bot
Copy link
Copy Markdown
Contributor

What

$WHILE_MAX is 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_MAX after 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_MAX with an escaped \$Template::Directive::WHILE_MAX in 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

  • New 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).
  • Existing t/while.t passes unchanged.
  • Full test suite passes.

Closes #149

🤖 Generated with Claude Code

…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>
@toddr toddr marked this pull request as ready for review April 26, 2026 14:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

WHILE_MAX setting does not seem to work [rt.cpan.org #54528]

1 participant