[perl #130431] [REGRESSION] Subclassing an Int no longer works flawlessly (my Foo $a .= new(42))

[email protected] ("Zoffix Znet via RT")
Newsgroups perl.perl6.compiler
Message-ID <[email protected]>
On Thu, 29 Dec 2016 19:26:07 -0800, [email protected] wrote:
> Another case:
> 
> class MyInt is Int { method even(){ self %% 2 } }; say [1..4].map({
> MyInt.new($_) }).grep({.even})
> 
> 
> Seems like it is a common thing to try, but I'm not going to say that
> it should
> work. Maybe it should throw a warning or something? If the warning can
> give
> clear instructions on how to do this kind of stuff, then I'd say we
> provided
> enough cakes.
> 
> On 2016-12-28 18:58:00, [email protected] wrote:
> > Code:
> > class Mebibytes is Int { method Str { (self/1024/1024).Int ~ "M" } };
> > my Mebibytes $a .= new(183456783); $a.say; # fancy enough?
> >
> >
> > Result (2016.09):
> > 174M
> >
> >
> > Result (HEAD):
> > Type check failed in assignment to $a; expected Mebibytes but got Int
> > (183456783)
> > in block <unit> at /tmp/4Vz0jddWQp line 1
> >
> >
> > Bisectable points to
> >
> https://github.com/rakudo/rakudo/commit/798c2e2dca34e5cf93da99d1f401eb161efca854
> >
> >
> > <Zoffix> AlexDaniel, please rakudobug it. I'll take a look tomorrow.
> > At least half of
> >
> https://github.com/rakudo/rakudo/commit/798c2e2dca34e5cf93da99d1f401eb161efca854
> > is wrong, because that comment lies; it doesn't give a "decoupled"
> > Int

This was already fixed awhile back and I'm 100% sure there are tests covering the issue as well (this was around when nqp::fromI_I was being introed to fix constant caching here)
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.