{
dVAR; dSP; dTOPss;
AV *av;
+ const I32 gimme = GIMME_V;
+ static const char return_array_to_lvalue_scalar[] = "Can't return hash to lvalue scalar context";
if (SvROK(sv)) {
wasref:
RETURN;
}
else if (LVRET) {
- if (GIMME == G_SCALAR)
- Perl_croak(aTHX_ "Can't return array to lvalue scalar context");
+ if (gimme != G_ARRAY)
+ Perl_croak(aTHX_ return_array_to_lvalue_scalar);
SETs((SV*)av);
RETURN;
}
RETURN;
}
else if (LVRET) {
- if (GIMME == G_SCALAR)
- Perl_croak(aTHX_ "Can't return array to lvalue"
- " scalar context");
+ if (gimme != G_ARRAY)
+ Perl_croak(aTHX_ return_array_to_lvalue_scalar);
SETs((SV*)av);
RETURN;
}
DIE(aTHX_ PL_no_usym, "an ARRAY");
if (ckWARN(WARN_UNINITIALIZED))
report_uninit(sv);
- if (GIMME == G_ARRAY) {
- (void)POPs;
+ if (gimme == G_ARRAY) {
+ SP--;
RETURN;
}
RETSETUNDEF;
RETURN;
}
else if (LVRET) {
- if (GIMME == G_SCALAR)
- Perl_croak(aTHX_ "Can't return array to lvalue"
- " scalar context");
+ if (gimme != G_ARRAY)
+ Perl_croak(aTHX_ return_array_to_lvalue_scalar);
SETs((SV*)av);
RETURN;
}
}
}
- if (GIMME == G_ARRAY) {
+ if (gimme == G_ARRAY) {
const I32 maxarg = AvFILL(av) + 1;
(void)POPs; /* XXXX May be optimized away? */
EXTEND(SP, maxarg);
}
SP += maxarg;
}
- else if (GIMME_V == G_SCALAR) {
+ else if (gimme == G_SCALAR) {
dTARGET;
const I32 maxarg = AvFILL(av) + 1;
SETi(maxarg);