# New Ticket Created by  Martin Barth 
# Please include the string:  [perl #131971]
# in the subject line of all future correspondence about this issue. 
# <URL: https://rt.perl.org/Ticket/Display.html?id=131971 >


class Foo {
     has $.class is required;

     method require-class {
         try {
             require ::($.class);

             CATCH {
                 default {
                     say .message;
                 }
             }
         }
     }

     method require-c {
         my $c = $.class;
         try {
             require ::($c);

             CATCH {
                 default {
                     say .message;
                 }
             }
         }
     }
}

# use something that you have installed or you get a "Couldn not find 
...." which is fine.
my $f = Foo.new(class => 'Bailador');

say 'works - or throws could not find Bailador';
$f.require-c;

say 'fails with "Too many positionals passed..."';
$f.require-class;

Reply via email to