$TB->current_test($curr_test+4);
eval q{ CCODE->{foo} };
-ok scalar($@ =~ /^Constant is not a HASH/);
+ok scalar($@ =~ /^Constant is not a HASH|Not a HASH reference/);
# Allow leading underscore
$| = 1;
BEGIN { require './test.pl' }
-plan tests => 5194;
+plan tests => 5198;
use Scalar::Util qw(tainted);
pass("RT 121362");
}
+package refsgalore {
+ use overload
+ '${}' => sub { \42 },
+ '@{}' => sub { [43] },
+ '%{}' => sub { { 44 => 45 } },
+ '&{}' => sub { sub { 46 } };
+}
+{
+ use feature 'postderef';
+ no warnings 'experimental::postderef';
+ tell myio; # vivifies *myio{IO} at compile time
+ use constant ioref => bless *myio{IO}, refsgalore::;
+ is ioref->$*, 42, '(overloaded constant that is not a scalar ref)->$*';
+ is ioref->[0], 43, '(ovrld constant that is not an array ref)->[0]';
+ is ioref->{44}, 45, "(ovrld const that is not a hash ref)->{key}";
+ is ioref->(), 46, '(overloaded constant that is not a sub ref)->()';
+}
{ # undefining the overload stash -- KEEP THIS TEST LAST
package ant;
/* Is it a constant from cv_const_sv()? */
if (SvROK(kidsv) && SvREADONLY(kidsv)) {
- SV * const rsv = SvRV(kidsv);
- const svtype type = SvTYPE(rsv);
- const char *badtype = NULL;
-
- switch (o->op_type) {
- case OP_RV2SV:
- if (type > SVt_PVMG)
- badtype = "a SCALAR";
- break;
- case OP_RV2AV:
- if (type != SVt_PVAV)
- badtype = "an ARRAY";
- break;
- case OP_RV2HV:
- if (type != SVt_PVHV)
- badtype = "a HASH";
- break;
- case OP_RV2CV:
- if (type != SVt_PVCV)
- badtype = "a CODE";
- break;
- }
- if (badtype)
- Perl_croak(aTHX_ "Constant is not %s reference", badtype);
return o;
}
if (SvTYPE(kidsv) == SVt_PVAV) return o;