fix: use do() instead of require() for compiled templates (GH #177)#427
Open
toddr-bot wants to merge 4 commits into
Open
fix: use do() instead of require() for compiled templates (GH #177)#427toddr-bot wants to merge 4 commits into
toddr-bot wants to merge 4 commits into
Conversation
Replace the delete-$INC-then-require hack with do(), which doesn't consult or modify %INC in the first place. This eliminates the need to manipulate global interpreter state just to reload compiled templates, as originally proposed in GH #79. Closes #177 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Restored the `eval { }` block around the `do $fpath` call, per @atoomic's review: `$@` is checked immediately after to detect load errors, so the `eval` block is needed to ensure `$@` reflects errors from this specific `do` call rather than stale errors from earlier code.
Contributor
Author
|
Recreated from #367 (auto-closed when the |
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
Replace
delete $INC{...}; require ...withdo ...inProvider::_load_compiled().Why
The compiled template loader manipulated
%INC(a global interpreter hash) to force reloads — deleting entries beforerequireto prevent the "already loaded" shortcut. This is a well-known antipattern that can interfere with other modules tracking loaded files. Issue #177 (opened by toddr) proposed switching todo(), which was the original approach in #79 but deferred at the time.How
do $fileexecutes the file and returns the last expression, just likerequire, but doesn't consult or modify%INC. This is a one-line behavioral change — the$@error handling remains identical. Updated comments to reflect the new approach.Testing
Full test suite passes (3170 tests across 116 files), including all 6 compile test files (
t/compile1.tthrought/compile6.t, 81 compile-specific tests).Closes #177
🤖 Generated with Claude Code