This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Deparse.pm: handle BEGIN { require expr }
authorDavid Mitchell <davem@iabyn.com>
Thu, 23 Feb 2017 14:33:05 +0000 (14:33 +0000)
committerDavid Mitchell <davem@iabyn.com>
Mon, 5 Jun 2017 11:52:17 +0000 (12:52 +0100)
commit0a30b526db0a91f5cad699185aecc65e6eef7965
treef829e93bb15332c559ee0bc88dd4309acd801267
parentf7f169a88ce4013295a6e0b5dc924e6d3b2d3aaa
Deparse.pm: handle BEGIN { require expr }

Deparse examines BEGIN subs to see if they look like

    BEGIN { require Foo; ... }

and if so deparses them as 'use Foo' instead.

However, it can't cope when Foo is an expression rather than a constant,
such as

    BEGIN {
        require($ENV{PERL_CORE} ? '../../t/test.pl' : './t/test.pl');
    }

and crashes.

This commit makes it instead recognise such op trees as not being part of
a 'use'.

Under TEST -deparse, this fixes the following unexpectedly failing
script:

    dist/threads/t/kill3.t

and fixes the following expected-to-fail scripts:

    dist/IO/t/io_file_export.t
    dist/IO/t/io_multihomed.t
    dist/IO/t/io_udp.t
    dist/threads/t/err.t
    dist/threads/t/kill2.t
    dist/threads/t/libc.t
Porting/deparse-skips.txt
lib/B/Deparse.pm