# New Ticket Created by Rob Hoelz # Please include the string: [perl #118985] # in the subject line of all future correspondence about this issue. # <URL: https://rt.perl.org:443/rt3/Ticket/Display.html?id=118985 >
Using a lexical regex in a method fails with a strange error: Nominal type check failed for parameter ''; expected HasMethod but got Cursor instead in regex anything at test.p6:34 in method INTERPOLATE at src/gen/CORE.setting:10730 in regex at test.p6:36 in method ACCEPTS at src/gen/CORE.setting:10894 in method ACCEPTS at src/gen/CORE.setting:703 in method parse at test.p6:36 in block at test.p6:45 The attached file includes examples.
use v6; sub parse(Str $input) { my regex anything { . } if $input ~~ /<anything>/ { } } class HasSub { sub parse(Str $input) { my regex anything { . } if $input ~~ /<anything>/ { } } method call-parse-sub(Str $input) { parse($input); } } class HasSubMethod { submethod parse(Str $input) { my regex anything { . } if $input ~~ /<anything>/ { } } } class HasMethod { method parse(Str $input) { my regex anything { . } if $input ~~ /<anything>/ { } } } my @forms = ( { parse('foo'); }, # no problems { HasSub.call-parse-sub('foo') }, # fails { HasSubMethod.parse('foo') }, # fails { HasMethod.parse('foo') }, # fails ); for @forms -> $form { try { $form(); CATCH { default { .say } } } }