On Mon, 21 Dec 2015 13:33:51 -0800, masak wrote:
> <masak> m: sub foo($x) { say (* == $x)($_) given $x }; foo(1); foo(2)
> <camelia> rakudo-moar cfb1f3: OUTPUT«TrueFalse»
> * masak submits rakudobug
>
> Examining the expression printed, it basically says "$x should be
> numerically equal to itself" in a circuitous way. Since this is true
> for any integer, I'd expect the program to print "True\nTrue\n".
>
> Here's what's wrong:
>
> <masak> m: sub foo($x) { say (* ~ $x)($_) given $x }; foo(1); foo(2)
> <camelia> rakudo-moar cfb1f3: OUTPUT«1121»
>
> That "1" there in "21" is from the first call to &foo -- it shouldn't
> be there any more. But something in the WhateverCode (* ~ $x) holds
> onto the old $x.
>
> <masak> this bug brought to you by: Refactoring™
> <lucasb> so... the WhateverCode is caching the first value it's
> *created* with?
> <masak> yes, but only if it's in a given
> <masak> m: sub foo($x) { say (* ~ $x)($x) }; foo(1); foo(2)
> <camelia> rakudo-moar cfb1f3: OUTPUT«1122»
Fudged tests preemptively added to S02-types/whatever.t in roast commit
4b2fef409.