fix: read WHILE_MAX at runtime instead of compile-time#340
Draft
Koan-Bot wants to merge 1 commit intoabw:masterfrom
Draft
fix: read WHILE_MAX at runtime instead of compile-time#340Koan-Bot wants to merge 1 commit intoabw:masterfrom
Koan-Bot wants to merge 1 commit intoabw:masterfrom
Conversation
The $WHILE_MAX value was interpolated as a literal number into the generated Perl code in Template::Directive::while(). This meant that changing $Template::Directive::WHILE_MAX after template compilation had no effect, and compiled-to-disk templates permanently baked in whatever value was set when they were first compiled. Generate code that references $Template::Directive::WHILE_MAX directly, so the value is always read at execution time. 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
Generate code that reads
$Template::Directive::WHILE_MAXat runtime instead of interpolating it as a literal number at compile-time.Why
The
while()method inTemplate::Directiveinterpolates$WHILE_MAXdirectly into the generated Perl code as a literal. This bakes the value in at template compilation time, so:$Template::Directive::WHILE_MAXafter compilation has no effectCOMPILE_DIR/COMPILE_EXT) permanently use whatever value was set when first compiledHow
Replace
$WHILE_MAXinterpolation in the heredoc with escaped\$Template::Directive::WHILE_MAXreferences, so the generated code reads the package variable at execution time.Testing
t/while_max_runtime.t: verify WHILE_MAX changes take effect without recompilation, including compiled-to-disk templates🤖 Generated with Claude Code