This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
treat when(index() > -1) as a boolean expression
authorDavid Mitchell <davem@iabyn.com>
Sat, 14 Jul 2018 09:47:04 +0000 (10:47 +0100)
committerDavid Mitchell <davem@iabyn.com>
Sat, 14 Jul 2018 09:59:25 +0000 (10:59 +0100)
commit6b877bbd2c071b3e0659fab552a74dc2ff7e08fb
tree0104ca516d1cd6b7df0b1e94106e1b68224b103f
parenta13f1de4e34633a275aa79d4e7874c2796bc0417
treat when(index() > -1) as a boolean expression

RT #133368

when(X) is normally compiled as when($_ ~~ X) *except* when X appears to
be a boolean expression, in which case it's used directly.

5.28.0 introduced an optimisation whereby comparisons involving index
like

    index(...) != -1

eliminated the comparison, and pp_index() returned a boolean value
directly. This defeated the 'look for a boolean op' mechanism, and so

    when(index(...) != -1)

and similar were being incorrectly compiled as

    when($_ ~~ (index(...) != -1))
op.c
t/op/switch.t