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
In a string enclosed in parens, a {}-interpolation can't access the topic $_ of a statement modifier #5291
Comments
From @smlsGolfed example: say ("{$_}") for <aa bb>; Expected behavior: Print the lines "aa" and "bb". Actual behavior: Prints two empty lines, and emits two "Use of uninitialized value $_ of type Any in string context" warnings. By comparison, all of the following variations works fine: say "{$_}" for <aa bb>; This means that the problem only occurs when all of the following situations coincide: 1) The topic $_ is set by a statement modifier (and not, say, the block form of `given`/`for`). This failure mode is very similar to one in RT #126569, so the two bugs are probably related. |
From @zoffixznet♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥ TODO-fudged tests added in Raku/roast@35eaee507f 🏁🏁🏁🏁🏁🏁🏁🏁🏁🏁🏁🏁🏁🏁🏁🏁🏁🏁🏁🏁🏁🏁🏁🏁🏁🏁🏁🏁🏁🏁🏁🏁🏁🏁🏁🏁🏁 Worth nothing this example. The value inside the for loop appears to be whatever $_ is outside the loop: zoffix@VirtualBox:~$ perl6 -e '$_ = "value"; say ("{$_}") for <aa bb>;' |
The RT System itself - Status changed from 'new' to 'open' |
From @smlsThis bug is still present in This is Rakudo version 2017.05-134-g0c5fe56cc built on MoarVM version 2017.05-25-g62bc54e9 |
From @skidsOn Sun, 28 May 2017 00:08:18 -0700, smls75@gmail.com wrote:
OK, keeping in mind that I have entirely, absolutely no idea what I am doing... I figured out that the block inside the string inside the parens is being annotated Resulting in the following one-character patch (drumroll please): Inline Patchdiff --git a/src/Perl6/Actions.nqp b/src/Perl6/Actions.nqp
index 36fa59b2b..6576f61b7 100644
--- a/src/Perl6/Actions.nqp
+++ b/src/Perl6/Actions.nqp
@@ -8953,7 +8953,7 @@ class Perl6::Actions is HLL::Actions does STDActions {
$*W.pop_lexpad();
if nqp::defined($migrate_stmt_id) {
migrate_blocks($*W.cur_lexpad(), $block, -> $b {
- !$b.ann('in_stmt_mod') && ($b.ann('statement_id') // -1) == $migrate_stmt_id
+ !$b.ann('in_stmt_mod') && ($b.ann('statement_id') // -1) >= $migrate_stmt_id
});
}
($*W.cur_lexpad())[0].push($block);
So, this is either the right fix, or a very wrong fix which might just break things in a way Other cases tested with this patch: $ perl6 -e 'say ("{$_}") given <aa bb>' |
From @AlexDanielAlso worth taking a look at https://rt-archive.perl.org/perl6/Ticket/Display.html?id=126569 On 2017-09-29 14:06:58, bri@abrij.org wrote:
|
From @skidsOn Mon, 02 Oct 2017 19:08:27 -0700, alex.jakimenko@gmail.com wrote:
I'm still running with that patch installed and yes, it does seem to |
From @zoffixznetOn Tue, 03 Oct 2017 09:38:23 -0700, bri@abrij.org wrote:
Thank you for the report. This is now fixed. Fix: rakudo/rakudo@1ee89b54074e80c |
@zoffixznet - Status changed from 'open' to 'resolved' |
Migrated from rt.perl.org#128054 (status was 'resolved')
Searchable as RT128054$
The text was updated successfully, but these errors were encountered: