Subject: | call_parser functions are not called on lexical subroutines |
I've attached both a test case and a patch for this issue. Basically, newCVREF
on an OP_CONST argument only ever creates a symbolic dereference, so
rv2cv_op_cv tries to look for the name of the keyword in the stash rather than
the pad. I'm not sure if that's correct behavior or not (not entirely sure what
the intended design is for a lot of this), but currently rv2cv_op_cv does look
in the pad if you provide it with an OP_PADCV instead. The patch just does a
pad lookup on the keyword name, and if it finds a lexical sub with that name,
creates an OP_PADANY instead of an OP_CONST to use as the child of the
OP_RV2CV.
Subject: | lexical-subs.diff |
diff -ur Devel-CallParser-0.002/lib/Devel/CallParser.xs Devel-CallParser-0.002-new/lib/Devel/CallParser.xs
--- Devel-CallParser-0.002/lib/Devel/CallParser.xs 2013-09-21 15:21:33.000000000 -0400
+++ Devel-CallParser-0.002-new/lib/Devel/CallParser.xs 2013-10-09 19:46:37.951301768 -0400
@@ -350,8 +350,27 @@
ENTER;
SAVEVPTR(PL_parser);
PL_parser = NULL;
- nmop = newSVOP(OP_CONST, 0, newSVpvn(keyword_ptr, keyword_len));
- nmop->op_private = OPpCONST_BARE;
+#if PERL_VERSION_GE(5, 17, 4)
+ {
+ PADOFFSET off;
+ SV *name;
+
+ name = sv_2mortal(newSVpvs("&"));
+ sv_catpvn(name, keyword_ptr, keyword_len);
+ off = pad_findmy_sv(name, 0);
+
+ if (off != NOT_IN_PAD) {
+ nmop = newOP(OP_PADANY, 0);
+ nmop->op_targ = off;
+ }
+ else {
+#endif
+ nmop = newSVOP(OP_CONST, 0, newSVpvn(keyword_ptr, keyword_len));
+ nmop->op_private = OPpCONST_BARE;
+#if PERL_VERSION_GE(5, 17, 4)
+ }
+ }
+#endif
cvop = newCVREF(0, nmop);
LEAVE;
if(!(cv = rv2cv_op_cv(cvop, 0))) {
Subject: | lexical-test.tar.gz |
Message body not shown because it is not plain text.