"Prototype mismatch" warnings when reexporting perl5i #228

Closed
daxim opened this Issue Feb 12, 2013 · 6 comments

2 participants

@daxim

This is related to issue 12 comment 334276 and likely #221.

I have written my own boilerplate module that includes perl5i. I did not use Toolkit, ToolSet or ingy's perl5 because autodie is special.

package MyBoilerplate;
use utf8;
use parent 'autodie';
use Module::Runtime qw(require_module);
our $VERSION = '1.000';

sub import {
    my ($class) = @_;
    my $caller = caller;

    require_module('strictures');
    strictures->import(1);

    require_module('perl5i::2');
    perl5i::2->import;

    eval <<"";
package $caller;
use lambda 'λ';
use perl5i::2;
use Moose qw(extends has with);
use MooseX::Method::Signatures;
use TryCatch;

    @_ = ($class, ':all');
    goto &autodie::import;
}

1;

I wouldn't wait until proper signature support arrives in perl5i, so I additionally include MXMS. I find that TryCatch works better than Try::Tiny, so I include TryCatch. The problem is that when using MyBoilerplate, the various exporter modules complain about subs being redefined, since both perl5i and e.g. MXMS provide a method.

Prototype mismatch: sub main::method (&) vs none at …/MooseX/Method/Signatures.pm line 104.
Prototype mismatch: sub main::try (&;@) vs () at …/Sub/Exporter.pm line 442.
Prototype mismatch: sub MyBoilerplate::open (*;$@) vs none at …/perl5i/2/UNIVERSAL.pm line 23.

This is a category S (severe) warning which is always enabled, see perldiag, and I can't seem to switch this off except editing the source code where the reexport happens. It would be nice if I could avoid the name clash by telling perl5i what to avoid importing, thus:

perl5i::2->import(-skip => [qw(autodie Signatures Try::Tiny)]);
use perl5i::2 -skip => [qw(autodie Signatures Try::Tiny)];

...patch removed, now in f6beed6

This should work, but the test suite fails, and I don't know enough for which reason and how to fix it.

@schwern

I've run into this problem too when combining perl5i and Method::Signatures. Your idea would be a great improvement.

I've made you a collaborator now. You can commit to the repository and make branches. It's preferable you do the work in a branch on the main repository, rather than in a fork, then other collaborators can work directly on the branch. The naming convention is issue/228. Branch and commit your patch and we'll see if we can get it working.

@schwern

Worked on it on the plane. Rather than figure out what went wrong with your change, I reverted your work and did it piece by piece starting with the easy stuff. Turns out we don't need to inherit from most anything to get the lexical magic, autodie being the exception (haha, a pun!) I'm not sure if that was cargo cult or if something changed, but the tests pass and I added additional checks for lexical functionality.

Multiple inheritance at runtime was the problem, C3/mro doesn't seem to be able to resolve that. Now that we're just inheriting from autodie its not an issue. I left autodie as a special case in import, rather than require special ordering for everything, but its still under feature control.

You chose to load modules inside an eval STRING like eval 'require File::Stat'. If it doesn't load it should throw an error, so I removed it.

Oh, and now perl5i loads about 5ms faster. Good work!

All that's left is documentation, I leave that to you.

@daxim

docs: 4afdb78

@schwern

Its a good start, let's get this merged so its easier to fix minor things.

Merge Monday unless there's objections.

@schwern schwern added a commit that referenced this issue Mar 20, 2013
@schwern schwern Merge branch 'issue/228'
Adding the ability to skip loading features.  For #228
58376b4
@schwern schwern added a commit that referenced this issue Mar 20, 2013
@schwern schwern Update the change log for #228 c58088d
@schwern

Merged and done!

@schwern schwern closed this Mar 20, 2013
@schwern schwern added a commit that referenced this issue Mar 20, 2013
@schwern schwern Rewrite the -skip docs to be less about the mechanics of import.
No need to go into the details of how import works.  The user
needs to know what the feature does.

For #228
4519fb2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment