#!/usr/bin/env raku
my Str $x;
if $x.starts-with( "[" )  &&
    $x.contains( "]" )
{ say "Passed"; } else { say "Failed"; }

K:\Windows\NtUtil>raku Contains.Test.pl6
Cannot resolve caller starts-with(Str:U: Str:D); none of these
signatures match

     (Cool:D: Cool:D $needle, :i(:$ignorecase)!, :m(:$ignoremark), *%_
--> Bool)
     (Cool:D: Cool:D $needle, :m(:$ignoremark)!, *%_ --> Bool)
     (Cool:D: Cool:D $needle, *%_ --> Bool)
     (Str:D: Str:D $needle, :i(:$ignorecase)!, :m(:$ignoremark), *%_ -->
Bool)
     (Str:D: Str:D $needle, :m(:$ignoremark)!, *%_ --> Bool)
     (Str:D: Str:D $needle, *%_ --> Bool)
   in block <unit> at Contains.Test.pl6 line 3

>  The function should just complain that the variable is not initialized.

Well, it is:
Cannot resolve caller starts-with(Str:U: Str:D);
...
in block <unit> at Contains.Test.pl6 line 3

it says:
For line 3:
if $x.starts-with( "[" )
looking for a possible method 'starts-with' with a signature of 2 params; an 
undefined string ('Str:U:') and a defined one ('Str:D:') failed - here's the 
list of the possible signatures raku currently has ..."

I'd not be surprise if you could write your own "starts-with(Str:U: Str:D); " 
method in raku and take care of this.  You could probably even have it "say"
You have an undefined String var in this call, not going to be able to do much 
useful matching against that.  Did you forget to initialize something?

________________________________
From: ToddAndMargo via perl6-users <perl6-us...@perl.org>
Sent: Wednesday, May 27, 2020 4:05 PM
To: perl6-users <perl6-us...@perl.org>
Subject: I reproduced one of the errors!

I managed to reproduce one of the errors I was getting.
I specifically did not initialize $x.  If I do, the
error goes away.  In my code, I did a "say $x" and it
said $x had something in it.  That is what threw me off


K:\Windows\NtUtil>raku -v
This is Rakudo version 2020.05.1 built on MoarVM version
2020.05 implementing Raku 6.d.



#!/usr/bin/env raku
my Str $x;
if $x.starts-with( "[" )  &&
    $x.contains( "]" )
{ say "Passed"; } else { say "Failed"; }



K:\Windows\NtUtil>raku Contains.Test.pl6
Cannot resolve caller starts-with(Str:U: Str:D); none of these
signatures match

     (Cool:D: Cool:D $needle, :i(:$ignorecase)!, :m(:$ignoremark), *%_
--> Bool)
     (Cool:D: Cool:D $needle, :m(:$ignoremark)!, *%_ --> Bool)
     (Cool:D: Cool:D $needle, *%_ --> Bool)
     (Str:D: Str:D $needle, :i(:$ignorecase)!, :m(:$ignoremark), *%_ -->
Bool)
     (Str:D: Str:D $needle, :m(:$ignoremark)!, *%_ --> Bool)
     (Str:D: Str:D $needle, *%_ --> Bool)
   in block <unit> at Contains.Test.pl6 line 3


The function should just complain that the variable is
not initialized.



--
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Computers are like air conditioners.
They malfunction when you open windows
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Reply via email to