This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
[perl #128260] Fix \substr %h
authorFather Chrysostomos <sprout@cpan.org>
Sun, 12 Jun 2016 13:19:47 +0000 (06:19 -0700)
committerFather Chrysostomos <sprout@cpan.org>
Sun, 12 Jun 2016 13:30:49 +0000 (06:30 -0700)
This is a follow-up to 79409ac8, which propagated substr’s own lvalue
context to the first argument only if it was one that would not croak
at compile time.

We can’t propagate OP_REFGEN lvalue context to the first argument,
as it causes the same bug for which #128260 was originally reported;
namely, that it prevents a hash or array from being flattened, causing
an unflattened aggregate to follow code paths that expect only sca-
lars, resulting in assertion failures:

$ ./perl -Ilib -e '%h=1..100; print ${\substr %h, 0}'
Assertion failed: (SvTYPE(sv) != SVt_PVAV && SvTYPE(sv) != SVt_PVHV && SvTYPE(sv) != SVt_PVFM), function Perl_sv_2pv_flags, file sv.c, line 2924.
Abort trap: 6
$ ./perl -Ilib -e '@h=1..100; print ${\vec @a, 0, 1}'
Assertion failed: (SvTYPE(sv) != SVt_PVAV && SvTYPE(sv) != SVt_PVHV && SvTYPE(sv) != SVt_PVFM), function Perl_sv_2pv_flags, file sv.c, line 2924.
Abort trap: 6


No differences found