> On 16 Mar 2015, at 18:50, Christian Bartolomaeus via RT 
> <bugs-comm...@bugs6.perl.org> wrote:
> $ perl6 -e 'say "abcd".index("xyz") == 0'
> Invocant requires an instance, but a type object was passed
>  in method Bridge at src/gen/m-CORE.setting:5603
>  in sub infix:<==> at src/gen/m-CORE.setting:5521
>  in block <unit> at -e:1

.index is speculated to return a StrPos object:

"The value returned is always a C<StrPos> object.  If the substring
is found, then the C<StrPos> represents the position of the first
character of the substring. If the substring is not found, a bare
C<StrPos> containing no position is returned.  This prototype C<StrPos>
evaluates to false because it's really a kind of undefined value.  Do not 
evaluate
as a number, because instead of returning -1 it will return 0 and issue
a warning.”

This would imply it should not fail, but return True *and* give a warning!


> $ perl6 -e 'say +Failure'
> Invocant requires an instance, but a type object was passed
>  in method Numeric at src/gen/m-CORE.setting:15733
>  in block <unit> at -e:1
> $ perl6 -e 'Failure == 0'
> Invocant requires an instance, but a type object was passed
>  in method Numeric at src/gen/m-CORE.setting:15733
>  in sub infix:<==> at src/gen/m-CORE.setting:5323
>  in block <unit> at -e:1

My feeling is that these should fail.  Failure’s are supposed not be thrown 
only when being checked for definedness.  Making it a number, does not meet 
that criterion in my opinion.




Liz

Reply via email to