]> git.vpit.fr Git - perl/modules/indirect.git/blobdiff - indirect.xs
Typos
[perl/modules/indirect.git] / indirect.xs
index 578c15447e5a3dfe1f815eeaed161731a67312f7..4ce10e59ce0dc8fae193abf93f0f81aa471bc3ba 100644 (file)
@@ -649,28 +649,35 @@ STATIC OP *(*indirect_old_ck_method)(pTHX_ OP *) = 0;
 STATIC OP *indirect_ck_method(pTHX_ OP *o) {
  if (indirect_hint()) {
   OP *op = cUNOPo->op_first;
-  const indirect_op_info_t *oi = indirect_map_fetch(op);
-  const char *s = NULL;
-  line_t line;
-  SV *sv;
 
-  if (oi && (s = oi->pos)) {
-   sv   = sv_2mortal(newSVpvn(oi->buf, oi->len));
-   line = oi->line; /* Keep the old line so that we really point to the first */
-  } else {
-   sv = cSVOPx_sv(op);
-   if (!SvPOK(sv) || (SvTYPE(sv) < SVt_PV))
-    goto done;
-   sv   = sv_mortalcopy(sv);
-   s    = indirect_find(sv, PL_oldbufptr);
-   line = CopLINE(&PL_compiling);
-  }
+  /* Indirect method call is only possible when the method is a bareword, so
+   * don't trip up on $obj->$meth. */
+  if (op && op->op_type == OP_CONST) {
+   const indirect_op_info_t *oi = indirect_map_fetch(op);
+   const char *s = NULL;
+   line_t line;
+   SV *sv;
+
+   if (oi && (s = oi->pos)) {
+    sv   = sv_2mortal(newSVpvn(oi->buf, oi->len));
+    /* Keep the old line so that we really point to the first line of the
+     * expression. */
+    line = oi->line;
+   } else {
+    sv = cSVOPx_sv(op);
+    if (!SvPOK(sv) || (SvTYPE(sv) < SVt_PV))
+     goto done;
+    sv   = sv_mortalcopy(sv);
+    s    = indirect_find(sv, PL_oldbufptr);
+    line = CopLINE(&PL_compiling);
+   }
 
-  o = CALL_FPTR(indirect_old_ck_method)(aTHX_ o);
-  /* o may now be a method_named */
+   o = CALL_FPTR(indirect_old_ck_method)(aTHX_ o);
+   /* o may now be a method_named */
 
-  indirect_map_store(o, s, sv, line);
-  return o;
+   indirect_map_store(o, s, sv, line);
+   return o;
+  }
  }
 
 done: