On Mon, 06 Mar 2017 12:51:12 -0800, TimTom wrote:
> If you pass an undefined value into starts-with, it loops forever
> because the Cool class has a wrapper method that casts the parameters
> to Str then invokes that. The Str class, however, defines the method
> as only taking a defined string. So it matches the Cool method again.
> Repeat.
> 
> 
> Changing the cool variant to only take a defined value causes it to
> die with an error message which is infinitely better: multi method
> starts-with(Cool:D: Str(Cool:D) $needle).  Or you could make a Str
> variant that returns some stock value. I don't really know nor care
> what the intended behavior is as long as it doesn't loop infinitely.
> From what I've seen in languages I have installed, the majority give
> an exception or otherwise crash and perl5 obviously treats it as the
> empty string.
> 
> 
> I presume there's a whole category of these in the Cool class that
> need the same treatment (like ends-with and contains).


Thank you for the report. This is now fixed.

Fix: https://github.com/rakudo/rakudo/commit/bfbe4298a7
Tests: https://github.com/perl6/roast/commit/0a39902ba1

Reply via email to