summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGurusamy Sarathy <gsar@cpan.org>1999-05-24 02:34:20 +0000
committerGurusamy Sarathy <gsar@cpan.org>1999-05-24 02:34:20 +0000
commit9675f7ac35061616b1770751dc4303671c1e0ebe (patch)
tree9292a3b5defc622fc0465fba8fdbfc0e984aaa8b
parent18228614d1dac2db099ef3d8846e53f44accce72 (diff)
downloadperl-9675f7ac35061616b1770751dc4303671c1e0ebe.tar.gz
oops, some files missing in change#3449
p4raw-link: @3449 on //depot/perl: 18228614d1dac2db099ef3d8846e53f44accce72 p4raw-id: //depot/perl@3450
-rw-r--r--op.c25
-rw-r--r--op.h1
-rw-r--r--toke.c1
3 files changed, 27 insertions, 0 deletions
diff --git a/op.c b/op.c
index 06977641ce..8f19121091 100644
--- a/op.c
+++ b/op.c
@@ -5412,6 +5412,31 @@ ck_subr(OP *o)
goto wrapref; /* autoconvert GLOB -> GLOBref */
else if (o2->op_type == OP_CONST)
o2->op_private &= ~OPpCONST_STRICT;
+ else if (o2->op_type == OP_ENTERSUB) {
+ /* accidental subroutine, revert to bareword */
+ OP *gvop = ((UNOP*)o2)->op_first;
+ if (gvop && gvop->op_type == OP_NULL) {
+ gvop = ((UNOP*)gvop)->op_first;
+ if (gvop) {
+ for (; gvop->op_sibling; gvop = gvop->op_sibling)
+ ;
+ if (gvop &&
+ (gvop->op_private & OPpENTERSUB_NOPAREN) &&
+ (gvop = ((UNOP*)gvop)->op_first) &&
+ gvop->op_type == OP_GV)
+ {
+ GV *gv = (GV*)((SVOP*)gvop)->op_sv;
+ OP *sibling = o2->op_sibling;
+ op_free(o2);
+ o2 = newSVOP(OP_CONST, 0,
+ newSVpvn(GvNAME(gv),
+ GvNAMELEN(gv)));
+ prev->op_sibling = o2;
+ o2->op_sibling = sibling;
+ }
+ }
+ }
+ }
scalar(o2);
break;
case '\\':
diff --git a/op.h b/op.h
index 03ea2afca4..125e115175 100644
--- a/op.h
+++ b/op.h
@@ -125,6 +125,7 @@ typedef U32 PADOFFSET;
#define OPpENTERSUB_DB 16 /* Debug subroutine. */
/* OP_RV2CV only */
#define OPpENTERSUB_AMPER 8 /* Used & form to call. */
+#define OPpENTERSUB_NOPAREN 128 /* bare sub call (without parens) */
/* OP_?ELEM only */
#define OPpLVAL_DEFER 16 /* Defer creation of array/hash elem */
/* for OP_RV2?V, lower bits carry hints */
diff --git a/toke.c b/toke.c
index df45a56980..441839b12b 100644
--- a/toke.c
+++ b/toke.c
@@ -3233,6 +3233,7 @@ int yylex(PERL_YYLEX_PARAM_DECL)
/* Resolve to GV now. */
op_free(yylval.opval);
yylval.opval = newCVREF(0, newGVOP(OP_GV, 0, gv));
+ yylval.opval->op_private |= OPpENTERSUB_NOPAREN;
PL_last_lop = PL_oldbufptr;
PL_last_lop_op = OP_ENTERSUB;
/* Is there a prototype? */