This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
fix ($lex = index(....)) == -1
authorDavid Mitchell <davem@iabyn.com>
Tue, 1 Aug 2017 07:19:42 +0000 (08:19 +0100)
committerDavid Mitchell <davem@iabyn.com>
Tue, 1 Aug 2017 07:19:42 +0000 (08:19 +0100)
commitdf84d7b01a41160c95881fe426bcb159d57d0ad6
treec2a36ed144d7f783acf54b24c1bfd0fcea915526
parent1fb2d101eac30e2ec4b826a4c493bb6f1232dc16
fix ($lex = index(....)) == -1

RT #131823

My recent commit v5.27.2-56-g7e8d786 optimised index() == -1 and similar.
It asserted that in such an expression, the index op's OPpTARGET_MY
flag couldn't be set. This was an incorrect assumption, obvious in
hindsight:

    ($lex = index(....)) == -1

gets compiled as

    <@> index[$r:2,3] sKP/TARGMY,2 ->c
       <0> ex-pushmark s ->9
       <0> padsv[$s:1,3] s ->a
       <$> const[PVMG "a"] s ->b
    <$> const[IV -1] s/FOLD ->d

The fix is simple: skip the optimisation if OPpTARGET_MY is present,
rather than assert failing.
op.c
t/op/index.t