This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Remove compile-time checking of rv2?v with const kid
authorFather Chrysostomos <sprout@cpan.org>
Mon, 25 Aug 2014 05:12:52 +0000 (22:12 -0700)
committerFather Chrysostomos <sprout@cpan.org>
Mon, 25 Aug 2014 05:49:19 +0000 (22:49 -0700)
commiteff754733a9f186c56767f2a49ab50e67600d3de
treea065c666cb9ba1391ff73a5b03371390e412c399
parent2445f2a6dfe26f6392ad410f27e34b382631a9db
Remove compile-time checking of rv2?v with const kid

There was code in op.c:ck_rvconst (which runs when creating a derefer-
ence op, such as rv2sv, rv2av, etc.) that would check that a constant
kid holding a reference pointed to something of the right type.  It
failed to take overloading into account.

The result was that these lines would fail to compile:

    constant_reference_to_hash_with_coderef_overloading->();
    constant_reference_to_sub_with_hashref_overloading->{key};
    constant_reference_to_sub_with_arrayref_overloading->[0];
    constant_reference_to_sub_with_scalarref_overloading->$*;

even though they should work.

Since the overloadedness could change any time, even checking for that
in op.c is incorrect.  The only correct fix is to remove this compile-
time check.  If something naughty gets through, it will be caught
at run time.

This fixes bugs #122607 and #69456.
dist/constant/t/constant.t
lib/overload.t
op.c