Repository navigation
Conversation
d7c8360 to
b9e3e92
Compare
235a1dc to
592dce4
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #194 +/- ##
==========================================
+ Coverage 88.64% 88.91% +0.27%
==========================================
Files 10 10
Lines 1136 1155 +19
Branches 272 275 +3
==========================================
+ Hits 1007 1027 +20
Misses 73 73
+ Partials 56 55 -1 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
605fdc8 to
2963cf4
Compare
oalders
left a comment
There was a problem hiding this comment.
Automated review. Ready to merge? With fixes.
The code is correct. 19 tests pass and lint passes. symbol_origins gives sensible results on real modules: Test::Most shows 26 subs from Test::More, POSIX shows 7 from Fcntl, and List::Util, Carp and Encode show none. The up-front load in dump-perl-exports gives a single clean error for a missing module, an invalid name and a syntax error.
Important: the committed cpanfile doesn't list Sub::Identify. The built dist gets it from AutoPrereqs, so CI is fine. But anyone installing from a checkout with cpm install --cpanfile cpanfile won't get it, and ExportInspector.pm will fail to compile. Run dzil build and commit the regenerated cpanfile; optionally declare it in dist.ini as well.
Minor:
- On Perl 5.42, Scalar::Util's
blessed,weakenand friends reportbuiltinas their origin. That's fine for the dump script, but worth a POD note beforereexported_symbolsis used to suggest a different import. dump-perl-exportsnow exits 1 for a module that can't be loaded. The script's POD doesn't mention this.- Test gaps: nothing covers
&-prefixed names or a name listed in both@EXPORTand@EXPORT_OK, and the unit test never asserts that$origin_varis left out ofsymbol_origins.
🤖 Review by Claude Code · Opus 5.5
| A HashRef mapping each sub in C<@EXPORT> and C<@EXPORT_OK> to the package in | ||
| which it was defined, per L<Sub::Identify/stash_name>. Empty if the module | ||
| cannot be loaded or does not use C<@EXPORT> and C<@EXPORT_OK> (e.g. | ||
| L<Sub::Exporter>). Loads the module into the current process, outside the |
There was a problem hiding this comment.
"Outside the sandbox" is misleading. The Sandbox is an eval in a random package in the same process, so the module is already loaded in-process. The real difference is that this uses require with no import. Suggest: "Requires the module directly (not via a sandboxed use) if it isn't already loaded."
| unless $INC{ module_notional_filename($module) } | ||
| || $self->_maybe_require_module($module); | ||
|
|
||
| # Only subs have an origin. |
There was a problem hiding this comment.
The filtering to subs happens in the loop below (the sigil skip and the exists & check), not where %names is built. Move this comment to the loop.
| $origins{$bare} | ||
| = Sub::Identify::stash_name( \&{ $module . q{::} . $bare } ); | ||
| } | ||
| use strict; |
There was a problem hiding this comment.
Nit: putting no strict 'refs' inside a bare block around the loop is the usual idiom, and it removes the need for this use strict;.
| ); | ||
|
|
||
| is_deeply( | ||
| [ sort $ei->reexported_symbols ], |
There was a problem hiding this comment.
The sort here hides whether reexported_symbols actually returns a sorted list, which the POD documents. Drop it, and give a fixture two re-exported subs so the order is tested.
8072cc9 to
85b9b26
Compare
Add symbol_origins and reexported_symbols to ExportInspector, mapping each sub in @EXPORT/@EXPORT_OK to the package where it was defined. dump-perl-exports shows an Origin column when a module re-exports subs, and exits 1 with a single error when the module can't be loaded. Thanks to Matt S Trout for pointing me at Devel::Wherefore. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
9619426 to
4218e7f
Compare
Summary
Attribute each exportable sub to the package where it was defined, using
Sub::Identify::stash_name. The idea comes fromDevel::Wherefore.@EXPORTand@EXPORT_OKsay what a module exports, not where each sub lives. A module can re-export subs it imported from elsewhere:Test::Mostre-exports most of its symbols fromTest::More,Test::Deep,Test::Exceptionand others.Changes
ExportInspector:symbol_originsmaps each sub in@EXPORT/@EXPORT_OKto its defining package. It skips variables and names with no sub behind them, strips&prefixes, and returns{}if the module can't be loaded.reexported_symbolsreturns the sorted list of subs defined in another package.stash_namestays correct for generated and__ANON__subs.dump-perl-exports:Origincolumn to the symbol tables when the module re-exports something. Output for other modules is unchanged.fatal_errorexport.Sub::Identifyis a new runtime dependency. AutoPrereqs picks it up;cpanfile,META.jsonandMakefile.PLare regenerated by dzil at release.Local::Origin*andt/ExportInspector/symbol-origins.t, plusOrigincolumn tests int/dump-perl-exports.t.Test::Scriptis now required at version 1.29 forscript_fails.Not yet done
Include.pm/Document.pmyet. A possible next step is to use the origin to resolve re-export facades.builtinas their origin on newer Perls (e.g.Scalar::Util::blessed). This is documented.Testing
prove -lr -j4 t: PASS (100 files, 345 tests)precious linton changed files: PASSCodex review (local)
Codex ran locally with its own sandbox bypassed (outer sandbox: nono).
Declined:
@Author::OALDERSalready picks it up fromuse Sub::IdentifyinExportInspector.pm.dzil buildregeneratescpanfile,META.jsonandMakefile.PLwithSub::Identifyand nodist.inientry, and those files aren't hand-edited between releases.[Prereqs / RuntimeRequires]only lists modules that need a minimum version.🤖 Generated with Claude Code · Opus 5.5