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

Scope flattening causes inner scope to lose value of topic variable #2601

Closed
SqrtNegInf opened this Issue Jan 10, 2019 · 7 comments

Comments

Projects
None yet
5 participants
@SqrtNegInf
Copy link

SqrtNegInf commented Jan 10, 2019

The Problem

The inner scope no longer knows the value of $_, prints 'True' instead of '2':

for 1..3 { { say $_ ; last } if $_ == 2 }

Environment

The problem appears with commit 541a4f16

This is Rakudo version 2018.12-171-g541a4f162 built on MoarVM version 2018.12-13-g473324ee3
implementing Perl 6.d.

@AlexDaniel

This comment has been minimized.

Copy link
Member

AlexDaniel commented Jan 11, 2019

COMMENT MOVED TO #2608

@jnthn

This comment has been minimized.

Copy link
Member

jnthn commented Jan 11, 2019

Let's create fresh issues for the regex boolean context issue. The original post is a straight bug that obviously wants fixing. The regex case, we probably do not want to spec; doing so is in contradiction with the design decision made in 6.d that $_ is no longer dynamically scoped. The best we can probably offer is a migration period.

@FCO

This comment has been minimized.

Copy link
Member

FCO commented Jan 14, 2019

<•SmokeMachine> Fernando Corrêa de Oliveira m: say do if 42 { $_ }
00:24 C<•camelia> combined, experimental evalbot rakudo-moar e87b7afb0: OUTPUT: «(LoweredAwayLexical)␤»
@AlexDaniel

This comment has been minimized.

Copy link
Member

AlexDaniel commented Jan 14, 2019

@jnthn done! Feel free to use this button:
image

@MasterDuke17

This comment has been minimized.

Copy link
Contributor

MasterDuke17 commented Jan 14, 2019

<•SmokeMachine> Fernando Corrêa de Oliveira m: say do if 42 { $_ }
00:24 C<•camelia> combined, experimental evalbot rakudo-moar e87b7afb0: OUTPUT: «(LoweredAwayLexical)␤»

Bisects to 541a4f1 also.

@jnthn

This comment has been minimized.

Copy link
Member

jnthn commented Jan 15, 2019

@AlexDaniel Ooh, I'd not seen that button. Neat!

jnthn added a commit to perl6/roast that referenced this issue Jan 15, 2019

jnthn added a commit that referenced this issue Jan 15, 2019

Do not copy $_ upon immediate block inlining
Otherwise, in some circumstances, it can lead to lexical accesses
that were meant to read outer $_ reading the lowered stub one. This
addresses the second issue that was reported in #2601.

jnthn added a commit to perl6/roast that referenced this issue Jan 15, 2019

@jnthn

This comment has been minimized.

Copy link
Member

jnthn commented Jan 15, 2019

Both issues - which were distinct - have been resolved and given tests.

@jnthn jnthn closed this Jan 15, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.