so that code thieves will have some correct code to steal.
Without intro_my(), the lexical subs installed in a ‘use’ block will
not be visible to the following statement, but only the one after it.
BEGIN blocks already get intro_my called, so it worked already with a
BEGIN block, but not with ‘use’.
padadd_STATE, 0, 0);
SvREFCNT_dec(PL_curpad[off]);
PL_curpad[off] = SvREFCNT_inc(cv);
+ intro_my();
LEAVE;
}
-use Test::More tests => 4;
+use Test::More tests => 5;
use XS::APItest;
our sub fribbler;
is fribbler(15), 30, 'our sub overrides XS-registered lexical sub';
}
+
+# With ‘use’ rather than explicit BEGIN:
+package Lexical::Exporter {
+ sub import { shift; ::lexical_import @_; return }
+}
+BEGIN { ++$INC{"Lexical/Exporter.pm"} }
+
+{
+ use Lexical::Exporter fribbler => sub { shift() . "foo" };
+ is fribbler("bar"), "barfoo";
+}