Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WhateverCode in given doesn't get refreshed when entering surrounding block in Rakudo #4901

Closed
p6rt opened this issue Dec 21, 2015 · 5 comments
Labels

Comments

@p6rt
Copy link

p6rt commented Dec 21, 2015

Migrated from rt.perl.org#126984 (status was 'resolved')

Searchable as RT126984$

@p6rt
Copy link
Author

p6rt commented Dec 21, 2015

From @masak

<masak> m​: sub foo($x) { say (* == $x)($_) given $x }; foo(1); foo(2)
<camelia> rakudo-moar cfb1f3​: OUTPUT«True␤False␤»
* 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«11␤21␤»

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«11␤22␤»

@p6rt
Copy link
Author

p6rt commented Sep 15, 2017

From @skids

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«True␤False␤»
* 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«11␤21␤»

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«11␤22␤»

Fudged tests preemptively added to S02-types/whatever.t in roast commit 4b2fef409.

@p6rt
Copy link
Author

p6rt commented Sep 15, 2017

The RT System itself - Status changed from 'new' to 'open'

@p6rt
Copy link
Author

p6rt commented Jan 26, 2018

From @zoffixznet

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«True␤False␤»
* 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«11␤21␤»

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«11␤22␤»

Thank you for the report. This is now fixed.

Fix​: rakudo/rakudo@1ee89b54074e80c
Test​: Raku/roast@2f2998733a2d8132c

@p6rt
Copy link
Author

p6rt commented Jan 26, 2018

@zoffixznet - Status changed from 'open' to 'resolved'

@p6rt p6rt closed this as completed Jan 26, 2018
@p6rt p6rt added the Bug label Jan 5, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant