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