You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm not sure why I can't reproduce this error with Method::Signatures alone; it seems like it ought to have the same problem, but it doesn't. Only when I'm using Method::Signatures::Modifiers with MooseX::Declare. This leads me to believe that I'm doing something bad (or not doing something good) in MSM, so I'm hesitant to just jump in and "fix" the problem by changing MS's %args to %__METHOD_SIGNATURES_ARGS_WHICH_YOU_SHOULD_NOT_USE or something like that. Seems a bit like cheating anyway.
Cheating is ok. If we're going to leak lexicals, let's leak ones that are unlikely to cause a clash.
The better fix is to wrap our internal lexicals in a block so they don't leak out. Essentially do this:
# method glitch(:$foo)
my $self = shift; # invocant
my $foo; # all variables declared in the signature
# Do any work in a block to hide our temporary lexicals
{
my %args = @_[0..$#_];
$foo = delete $args{foo};
Method::Signatures->named_param_error(\%args) if %args;
Method::Signatures->too_many_args_error(1) if @_ > 2;
}
I've got a gist which demonstrates the error.
I'm not sure why I can't reproduce this error with
Method::Signatures
alone; it seems like it ought to have the same problem, but it doesn't. Only when I'm usingMethod::Signatures::Modifiers
withMooseX::Declare
. This leads me to believe that I'm doing something bad (or not doing something good) in MSM, so I'm hesitant to just jump in and "fix" the problem by changing MS's%args
to%__METHOD_SIGNATURES_ARGS_WHICH_YOU_SHOULD_NOT_USE
or something like that. Seems a bit like cheating anyway.@schwern: Thoughts?
The text was updated successfully, but these errors were encountered: