Skip Menu |
Report information
Id: 76294
Status: open
Priority: 0/
Queue: perl6

Owner: Nobody
Requestors: masak <cmasak [at] gmail.com>
Cc:
AdminCc:

Severity: (no value)
Tag: Bug
Platform: (no value)
Patch Status: (no value)
VM: (no value)



Subject: [BUG] Can't numify Failure in Rakudo
Date: Wed, 30 Jun 2010 16:48:28 +0200
To: rakudobug [...] perl.org
From: Carl Mäsak <cmasak [...] gmail.com>
Download (untitled) / with headers
text/plain 528b
<masak> rakudo: say "abcd".index("xyz") == 0 <p6eval> rakudo aa015a: OUTPUT«Method 'Bridge' not found for invocant of class 'Failure' [...] <masak> arnsholt: possible issue :) * masak submits rakudobug <masak> rakudo: Failure == 0 <p6eval> rakudo aa015a: OUTPUT«Method 'Bridge' not found for invocant of class [...] * masak is not sure he likes .Bridge :/ Might be that comparing Failure (or any non-numeric type object, for that matter) with any number should give a warning or something, but it should not give this error.
Download (untitled) / with headers
text/plain 209b
As colomon++ pointed out, this works: <masak> rakudo: say +Failure <p6eval> rakudo 7df2c2: OUTPUT«Use of uninitialized value in numeric context␤0␤» So it's rather any *implied* numification that fails.
RT-Send-CC: perl6-compiler [...] perl.org
Download (untitled) / with headers
text/plain 812b
On Wed Jun 30 07:48:56 2010, masak wrote: Show quoted text
> <masak> rakudo: say "abcd".index("xyz") == 0 > <p6eval> rakudo aa015a: OUTPUT�Method 'Bridge' not found for invocant > of class 'Failure' [...] > <masak> arnsholt: possible issue :) > * masak submits rakudobug > <masak> rakudo: Failure == 0 > <p6eval> rakudo aa015a: OUTPUT�Method 'Bridge' not found for invocant > of class [...] > * masak is not sure he likes .Bridge :/ > > Might be that comparing Failure (or any non-numeric type object, for > that matter) with any number should give a warning or something, but > it should not give this error.
It now warns: 00:43 < [Coke]> rakudo: say "abcd".index("xyz") == 0 00:43 <+p6eval> rakudo cbdd9b: OUTPUT«Use of uninitialized value in numeric context␤Bool::True␤» -- Will "Coke" Coleda
RT-Send-CC: perl6-compiler [...] perl.org
Download (untitled) / with headers
text/plain 1.1k
On Mon Sep 19 21:43:52 2011, coke wrote: Show quoted text
> On Wed Jun 30 07:48:56 2010, masak wrote:
> > <masak> rakudo: say "abcd".index("xyz") == 0 > > <p6eval> rakudo aa015a: OUTPUT�Method 'Bridge' not found for invocant > > of class 'Failure' [...] > > <masak> arnsholt: possible issue :) > > * masak submits rakudobug > > <masak> rakudo: Failure == 0 > > <p6eval> rakudo aa015a: OUTPUT�Method 'Bridge' not found for invocant > > of class [...] > > * masak is not sure he likes .Bridge :/ > > > > Might be that comparing Failure (or any non-numeric type object, for > > that matter) with any number should give a warning or something, but > > it should not give this error.
> > It now warns: > > 00:43 < [Coke]> rakudo: say "abcd".index("xyz") == 0 > 00:43 <+p6eval> rakudo cbdd9b: OUTPUT«Use of uninitialized value in numeric > context␤Bool::True␤» > >
Current behavior: Show quoted text
> say +Failure
Parameter '' requires an instance, but a type object was passed Show quoted text
> say "abcd".index("xyz") == 0
Parameter '' requires an instance, but a type object was passed Show quoted text
> Failure == 0
use of uninitialized variable $max of type Failure in numeric context False -- Will "Coke" Coleda
RT-Send-CC: perl6-compiler [...] perl.org
Download (untitled) / with headers
text/plain 769b
Now all three commands complain about a type object being passed when an instance is required: $ 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 '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 $ 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 Is that reasonable or what would be an adequate error message?
To: bugs-comment [...] bugs6.perl.org
Subject: Re: [perl #76294] [BUG] Can't implicitly numify Failure in Rakudo
From: Elizabeth Mattijsen <liz [...] dijkmat.nl>
CC: perl6-compiler [...] perl.org
Date: Mon, 16 Mar 2015 21:13:11 +0100
Download (untitled) / with headers
text/plain 1.4k
Show quoted text
> On 16 Mar 2015, at 18:50, Christian Bartolomaeus via RT <bugs-comment@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! Show quoted text
> $ 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
RT-Send-CC: perl6-compiler [...] perl.org
Download (untitled) / with headers
text/plain 1.6k
On Mon Mar 16 13:13:35 2015, elizabeth wrote: Show quoted text
> > On 16 Mar 2015, at 18:50, Christian Bartolomaeus via RT <bugs- > > comment@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
StrPos is gone from the design docs, so this needs to be revisited. -- Will "Coke" Coleda


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

For issues related to this RT instance (aka "perlbug"), please contact perlbug-admin at perl.org