fix: use do() instead of require() for compiled templates (GH #177)#367
Open
toddr-bot wants to merge 4 commits intoabw:masterfrom
Open
fix: use do() instead of require() for compiled templates (GH #177)#367toddr-bot wants to merge 4 commits intoabw:masterfrom
toddr-bot wants to merge 4 commits intoabw:masterfrom
Conversation
atoomic
requested changes
Apr 4, 2026
Collaborator
atoomic
left a comment
There was a problem hiding this comment.
need some extra work, view comment about eval block
| # Unlike require(), do() doesn't consult or modify %INC, | ||
| # so we avoid the previous hack of deleting %INC entries | ||
| # to force reloads (see GH #177). | ||
| my $compiled = do $fpath; |
Collaborator
There was a problem hiding this comment.
We should still preserve the eval block as $@ is used the line just after
Collaborator
|
@toddr-bot rebase and view comment from #367 (comment) |
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 abw#79. Closes abw#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
Rebase: fix: use do() instead of require() for compiled templates (GH #177)Branch Diff: 1 file changed, 7 insertions(+), 18 deletions(-) Review feedback was analyzed and applied. Changes
Actions
CICI will be checked asynchronously. Automated by Kōan |
7935f9e to
a40172a
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.
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