summaryrefslogtreecommitdiff
path: root/pp_hot.c
diff options
context:
space:
mode:
authorSimon Cozens <simon@netthink.co.uk>2000-12-28 20:33:13 +0000
committerJarkko Hietaniemi <jhi@iki.fi>2000-12-28 21:52:42 +0000
commitd804643f1d3e26c9c696bb1ebe8344dd5f1c8f6d (patch)
tree62c294e518d95ff78b72649c44e4f49b5eec3a30 /pp_hot.c
parent0d73d187eb6a7f76dde07ae608622944dbccd4e9 (diff)
downloadperl-d804643f1d3e26c9c696bb1ebe8344dd5f1c8f6d.tar.gz
Re: [PATCH] Warn on use of reference as array elem
Message-ID: <20001228203313.A2607@deep-dark-truthful-mirror.perlhacker.org> p4raw-id: //depot/perl@8234
Diffstat (limited to 'pp_hot.c')
-rw-r--r--pp_hot.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/pp_hot.c b/pp_hot.c
index 2904d9f6e2..a24aa1dd7f 100644
--- a/pp_hot.c
+++ b/pp_hot.c
@@ -2815,12 +2815,15 @@ PP(pp_aelem)
{
djSP;
SV** svp;
- IV elem = POPi;
+ SV* elemsv = POPs;
+ IV elem = SvIV(elemsv);
AV* av = (AV*)POPs;
U32 lval = PL_op->op_flags & OPf_MOD;
U32 defer = (PL_op->op_private & OPpLVAL_DEFER) && (elem > AvFILL(av));
SV *sv;
+ if (SvROK(elemsv) && ckWARN(WARN_MISC))
+ Perl_warner(aTHX_ WARN_MISC, "Use of reference \"%s\" as array index", SvPV_nolen(elemsv));
if (elem > 0)
elem -= PL_curcop->cop_arybase;
if (SvTYPE(av) != SVt_PVAV)