On Wed, 28 Dec 2016 18:58:00 -0800, alex.jakime...@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
Looking deeper into it, the comment doesn't lie, it does seem to work to decouple from cached constants: # HEAD <Zoffix> m: my $y = Int.new: 2; my $x = 2; 2 does role Foo {}; dd $y <camelia> rakudo-moar 19df35: OUTPUT«Int $y = 2» # 2012.15 <Zoffix> committable6, 2015.12 my $y = Int.new: 2; my $x = 2; 2 does role Foo {}; dd $y <committable6> Zoffix, ¦«2015.12»: Int+{Foo} $y = 2 Can't figure out how to get the cake and eat it too, though... I can either make it create a new self.WHAT maintaining subclassing object OR handle huge values like 2⁶⁴ correctly. Other than doing something stupid, like coercing it to Str and then using nqp::fromstr_I :/