develooper Front page | perl.perl6.compiler | Postings from February 2018

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

Thread Previous
From:
Zoffix Znet via RT
Date:
February 9, 2018 22:47
Subject:
[perl #130431] [REGRESSION] Subclassing an Int no longer worksflawlessly (my Foo $a .= new(42))
Message ID:
rt-4.0.24-22305-1518216431-801.130431-15-0@perl.org
On Thu, 29 Dec 2016 19:26:07 -0800, alex.jakimenko@gmail.com 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, alex.jakimenko@gmail.com 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)

Thread Previous


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About