const bool localizing = PL_op->op_private & OPpLVAL_INTRO;
bool preeminent = TRUE;
- assert(SvTYPE(hv) == SVt_PVHV);
+ if (SvTYPE(hv) != SVt_PVHV)
+ RETPUSHUNDEF;
if (localizing) {
MAGIC *mg;
PERL_CONTEXT *cx;
SV *sv;
- if (CxMULTICALL(&cxstack[cxstack_ix]))
+ if (CxMULTICALL(&cxstack[cxstack_ix])) {
+ /* entry zero of a stack is always PL_sv_undef, which
+ * simplifies converting a '()' return into undef in scalar context */
+ assert(PL_stack_sp > PL_stack_base || *PL_stack_base == &PL_sv_undef);
return 0;
+ }
POPBLOCK(cx,newpm);
cxstack_ix++; /* temporarily protect top context */