diff options
author | Jesse Luehrs <doy@tozt.net> | 2013-07-04 14:22:19 -0400 |
---|---|---|
committer | Jesse Luehrs <doy@tozt.net> | 2013-07-04 14:22:19 -0400 |
commit | 79fe1ab8e547951f254e387eb81a910a8196c558 (patch) | |
tree | 2920018628ed47232fd3bccf2237f1cc63795e06 /lib | |
parent | 48656ef560302c9e9864b84b2f95f266799d88e3 (diff) | |
download | reply-79fe1ab8e547951f254e387eb81a910a8196c558.tar.gz reply-79fe1ab8e547951f254e387eb81a910a8196c558.zip |
alias lexicals to their actual values
this makes them work more correctly with closures, and variables in the
environment that come from other locations (like in Carp::Reply)
Diffstat (limited to 'lib')
-rw-r--r-- | lib/Reply/Plugin/Defaults.pm | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/lib/Reply/Plugin/Defaults.pm b/lib/Reply/Plugin/Defaults.pm index 991b807..adf5c0e 100644 --- a/lib/Reply/Plugin/Defaults.pm +++ b/lib/Reply/Plugin/Defaults.pm @@ -13,6 +13,7 @@ use warnings; use base 'Reply::Plugin'; +use Devel::LexAlias 'lexalias'; use Eval::Closure; sub new { @@ -52,12 +53,18 @@ sub compile { my $prefix = "package $self->{package};\n$PREFIX"; - return eval_closure( + my $code = eval_closure( source => "sub {\n$prefix;\n$line\n}", terse_error => 1, environment => $env, %args, ); + + for my $name (keys %$env) { + lexalias($code, $name, $env->{$name}); + } + + return $code; } sub lexical_environment { |