On Sun, Jan 15, 2012 at 02:18:43PM -0500, Matthew Horsfall (alh) wrote: > Nicholas, > > Attached is a patch to your branch smoke-me/deprecate-any-defined-array to > properly warn on defined(%hash = (...)). I've added a number of tests and > also updated the few tests that now warned about the deprecation of > defined(...) to not warn. Aha. I'd fixed those tests in commit 33f89799d9328f3d before reading this message. (And my fault for not spotting them before) I think that that needs to be a distinct commit from your intended change. > If my method for getting the lhs of an OP_AASSIGN is correct, I think I'll > make a macro of it and fix a few other related outstanding bugs using that > new macro. I'm really not familiar with the structure of the optree, so I'm not actually the right person to confirm this. I can look at it and say "it sure looks like it works", and even compare it to some "typical" B::Concise output, but that's not actually useful. I don't know the "unknown unknowns" here - whether there are any corner cases that it misses. git's diff isn't being totally helpful here, mixing up all the +s and -s Your new code is: if (ckWARN_d(WARN_DEPRECATED)) { register OP *kid = o->op_flags & OPf_KIDS ? cUNOPo->op_first : NULL; if (kid) { OPCODE type = kid->op_type; /* OP_AASSIGN? Walk the op tree to get what's being assigned to */ if (type == OP_AASSIGN) { type = cUNOPx(cBINOPx(kid)->op_last)->op_first->op_sibling->op_type; } switch (type) { case OP_RV2AV: case OP_PADAV: Perl_ck_warner_d(aTHX_ packWARN(WARN_DEPRECATED), "defined(@array) is deprecated"); Perl_ck_warner_d(aTHX_ packWARN(WARN_DEPRECATED), "\t(Maybe you should just omit the defined()?)\n"); break; case OP_RV2HV: case OP_PADHV: Perl_ck_warner_d(aTHX_ packWARN(WARN_DEPRECATED), "defined(%%hash) is deprecated"); Perl_ck_warner_d(aTHX_ packWARN(WARN_DEPRECATED), "\t(Maybe you should just omit the defined()?)\n"); break; default: /* no warning */ break; } } } *I* simply don't know if that is sufficiently correct. I am not the droids you're looking for. Nicholas ClarkThread Previous | Thread Next