#include "EXTERN.h"
#define PERL_IN_OP_C
#include "perl.h"
+#include "keywords.h"
/* #define PL_OP_SLAB_ALLOC */
STATIC void
S_no_bareword_allowed(pTHX_ OP *o)
{
- Perl_warn(aTHX_ "Bareword \"%s\" not allowed while \"strict subs\" in use",
- SvPV_nolen(cSVOPo->op_sv));
- ++PL_error_count;
+ qerror(Perl_mess(aTHX_
+ "Bareword \"%s\" not allowed while \"strict subs\" in use",
+ SvPV_nolen(cSVOPo->op_sv)));
}
/* "register" allocation */
SV *sv;
if (!(
+ PL_in_my == KEY_our ||
isALPHA(name[1]) ||
(PL_hints & HINT_UTF8 && (name[1] & 0xc0) == 0xc0) ||
- name[1] == '_' && (int)strlen(name) > 2))
+ name[1] == '_' && (int)strlen(name) > 2 ))
{
if (!isPRINT(name[1]) || strchr("\t\n\r\f", name[1])) {
/* 1999-02-27 mjd@plover.com */
&& strEQ(name, SvPVX(sv)))
{
Perl_warner(aTHX_ WARN_UNSAFE,
- "\"my\" variable %s masks earlier declaration in same %s",
- name, (SvIVX(sv) == PAD_MAX ? "scope" : "statement"));
+ "\"%s\" variable %s masks earlier declaration in same %s",
+ (PL_in_my == KEY_our ? "our" : "my"),
+ name,
+ (SvIVX(sv) == PAD_MAX ? "scope" : "statement"));
break;
}
}
SvSTASH(sv) = (HV*)SvREFCNT_inc(PL_in_my_stash);
PL_sv_objcount++;
}
+ if (PL_in_my == KEY_our)
+ SvFLAGS(sv) |= SVpad_OUR;
av_store(PL_comppad_name, off, sv);
SvNVX(sv) = (NV)PAD_MAX;
SvIVX(sv) = 0; /* Not yet introduced--see newSTATEOP */
SvNVX(namesv) = (NV)PL_curcop->cop_seq;
SvIVX(namesv) = PAD_MAX; /* A ref, intro immediately */
SvFAKE_on(namesv); /* A ref, not a real var */
+ if (SvFLAGS(sv) & SVpad_OUR)/* An "our" variable */
+ SvFLAGS(namesv) |= SVpad_OUR;
if (SvOBJECT(sv)) { /* A typed var */
SvOBJECT_on(namesv);
(void)SvUPGRADE(namesv, SVt_PVMG);
seq > I_32(SvNVX(sv)))) &&
strEQ(SvPVX(sv), name))
{
- if (SvIVX(sv))
+ if (SvIVX(sv) || SvFLAGS(sv) & SVpad_OUR)
return (PADOFFSET)off;
pendoff = off; /* this pending def. will override import */
}
if (kid->op_type == OP_METHOD_NAMED
|| kid->op_type == OP_METHOD)
{
- OP *new;
+ OP *newop;
if (kid->op_sibling || kid->op_next != kid) {
yyerror("panic: unexpected optree near method call");
break;
}
- NewOp(1101, new, 1, OP);
- new->op_type = OP_RV2CV;
- new->op_ppaddr = PL_ppaddr[OP_RV2CV];
- new->op_next = new;
- kid->op_sibling = new;
- new->op_private |= OPpLVAL_INTRO;
+ NewOp(1101, newop, 1, OP);
+ newop->op_type = OP_RV2CV;
+ newop->op_ppaddr = PL_ppaddr[OP_RV2CV];
+ newop->op_next = newop;
+ kid->op_sibling = newop;
+ newop->op_private |= OPpLVAL_INTRO;
break;
}
my_kid(kid, attrs);
} else if (type == OP_UNDEF) {
return o;
+ } else if (type == OP_RV2SV || /* "our" declaration */
+ type == OP_RV2AV ||
+ type == OP_RV2HV) { /* XXX does this let anything illegal in? */
+ return o;
} else if (type != OP_PADSV &&
type != OP_PADAV &&
type != OP_PADHV &&
&& !(kkid->op_private & OPpLVAL_INTRO))
{
/* Concat has problems if target is equal to right arg. */
- if (kid->op_type == OP_CONCAT
- && kLISTOP->op_first->op_sibling->op_type == OP_PADSV
- && kLISTOP->op_first->op_sibling->op_targ == kkid->op_targ)
- {
- return o;
+ if (kid->op_type == OP_CONCAT) {
+ if (kLISTOP->op_first->op_sibling->op_type == OP_PADSV
+ && kLISTOP->op_first->op_sibling->op_targ == kkid->op_targ)
+ return o;
}
- if (kid->op_type == OP_JOIN) {
- /* do_join has problems the arguments coincide with target.
+ else if (kid->op_type == OP_JOIN) {
+ /* do_join has problems if the arguments coincide with target.
In fact the second argument *can* safely coincide,
but ignore=pessimize this rare occasion. */
OP *arg = kLISTOP->op_first->op_sibling; /* Skip PUSHMARK */
arg = arg->op_sibling;
}
}
+ else if (kid->op_type == OP_QUOTEMETA) {
+ /* quotemeta has problems if the argument coincides with target. */
+ if (kLISTOP->op_first->op_type == OP_PADSV
+ && kLISTOP->op_first->op_targ == kkid->op_targ)
+ return o;
+ }
kid->op_targ = kkid->op_targ;
/* Now we do not need PADSV and SASSIGN. */
kid->op_sibling = o->op_sibling; /* NULL */
}
OP *
+Perl_ck_join(pTHX_ OP *o)
+{
+ if (ckWARN(WARN_SYNTAX)) {
+ OP *kid = cLISTOPo->op_first->op_sibling;
+ if (kid && kid->op_type == OP_MATCH) {
+ char *pmstr = "STRING";
+ if (kPMOP->op_pmregexp)
+ pmstr = kPMOP->op_pmregexp->precomp;
+ Perl_warner(aTHX_ WARN_SYNTAX,
+ "/%s/ should probably be written as \"%s\"",
+ pmstr, pmstr);
+ }
+ }
+ return ck_fun(o);
+}
+
+OP *
Perl_ck_subr(pTHX_ OP *o)
{
dTHR;