Skip Menu |
Report information
Id: 121154
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] Int type object is much stricter with infix:<%> than Any in Rakudo
To: rakudobug [...] perl.org
From: Carl Mäsak <cmasak [...] gmail.com>
Date: Mon, 3 Feb 2014 14:44:11 +0100
Download (untitled) / with headers
text/plain 1.5k
<masak> r: subset Odd of Int where { $_ % 2 }; my Odd $o; say $o; say $o % 2 <camelia> rakudo-parrot 4a74e7: OUTPUT«(Odd)␤Invocant requires an instance, but a type object was passed [...] <camelia> ..rakudo-jvm 4a74e7: OUTPUT«(Odd)␤Cannot look up attributes in a type object [...] <camelia> ..rakudo-moar 4a74e7: OUTPUT«(Odd)␤Invocant requires an instance, but a type object was passed [...] <masak> huh. <masak> r: my Int $i; say $i % 2 <camelia> rakudo-moar 4a74e7: OUTPUT«Invocant requires an instance, but a type object was passed [...] <camelia> ..rakudo-parrot 4a74e7: OUTPUT«Invocant requires an instance, but a type object was passed [...] <camelia> ..rakudo-jvm 4a74e7: OUTPUT«Cannot look up attributes in a type object [...] <masak> I don't remember infix:<%> behaving like that. <masak> I expected it to warn, but assume that an undefined Int numifies to 0. <masak> r: my Int $i; try say $i % 2; say "alive" <camelia> rakudo-parrot 4a74e7, rakudo-jvm 4a74e7, rakudo-moar 4a74e7: OUTPUT«alive␤» <masak> n: my Int $i; try say $i % 2; say "alive" <camelia> niecza v24-109-g48a8de3: OUTPUT«0␤alive␤» <masak> I say Niecza has it right. any comments from anyone before I submit a rakudobug? <masak> r: my $x; say $x % 2 <camelia> rakudo-parrot 4a74e7: OUTPUT«use of uninitialized value of type Any in numeric context [...] ␤0␤» <camelia> ..rakudo-jvm 4a74e7, rakudo-moar 4a74e7: OUTPUT«use of uninitialized value of type Any in numeric context␤0␤» <masak> that's what I expect from Int undefined values, too. * masak submits rakudobug
So the gist of it is that Any % 2 is 0 but Int % 2 is an error. Still reproducible (2017.11, HEAD(5929887))

On 2014-02-03 05:44:28, masak wrote:
Show quoted text
> <masak> r: subset Odd of Int where { $_ % 2 }; my Odd $o; say $o; say
> $o % 2
> <camelia> rakudo-parrot 4a74e7: OUTPUT«(Odd)␤Invocant requires an
> instance, but a type object was passed [...]
> <camelia> ..rakudo-jvm 4a74e7: OUTPUT«(Odd)␤Cannot look up attributes
> in a type object [...]
> <camelia> ..rakudo-moar 4a74e7: OUTPUT«(Odd)␤Invocant requires an
> instance, but a type object was passed [...]
> <masak> huh.
> <masak> r: my Int $i; say $i % 2
> <camelia> rakudo-moar 4a74e7: OUTPUT«Invocant requires an instance,
> but a type object was passed [...]
> <camelia> ..rakudo-parrot 4a74e7: OUTPUT«Invocant requires an
> instance, but a type object was passed [...]
> <camelia> ..rakudo-jvm 4a74e7: OUTPUT«Cannot look up attributes in a
> type object [...]
> <masak> I don't remember infix:<%> behaving like that.
> <masak> I expected it to warn, but assume that an undefined Int
> numifies to 0.
> <masak> r: my Int $i; try say $i % 2; say "alive"
> <camelia> rakudo-parrot 4a74e7, rakudo-jvm 4a74e7, rakudo-moar 4a74e7:
> OUTPUT«alive␤»
> <masak> n: my Int $i; try say $i % 2; say "alive"
> <camelia> niecza v24-109-g48a8de3: OUTPUT«0␤alive␤»
> <masak> I say Niecza has it right. any comments from anyone before I
> submit a rakudobug?
> <masak> r: my $x; say $x % 2
> <camelia> rakudo-parrot 4a74e7: OUTPUT«use of uninitialized value of
> type Any in numeric context [...] ␤0␤»
> <camelia> ..rakudo-jvm 4a74e7, rakudo-moar 4a74e7: OUTPUT«use of
> uninitialized value of type Any in numeric context␤0␤»
> <masak> that's what I expect from Int undefined values, too.
> * masak submits rakudobug




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