The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.
#!/usr/bin/perl -w



use Test::More tests => 1;

my $warnings;
BEGIN {
    $^WARN_HOOK = sub { $warnings = @_[0]->{?description} };
}

do {
    package Foo;
    use fields < qw(thing);
};

do {
    package Bar;
    use fields < qw(stuff);
    use base < qw(Foo);
};

main::like $warnings,
       '/^Bar is inheriting from Foo but already has its own fields!/',
       'Inheriting from a base with protected fields warns';