-
Notifications
You must be signed in to change notification settings - Fork 602
Open
Labels
Description
While investigating issues around refalias, declared_refs, and the upcoming PPC0034 (refalias in signatures), I encountered the following cornercase:
use v5.36;
use experimental qw( refaliasing declared_refs );
my \@arr = [1, 2, 3];
my sub inner { say "Inside inner, array is <@arr>"; }
say "Outside, array is <@arr>";
inner();It produces output, showing that while the refalias affected the @arr variable in the outer scope, it did not affect the one captured by the inner sub:
Outside, array is <1 2 3>
Inside inner, array is <>
A slight modification of the program to put the lexical sub in its own nested block makes it behave as expected:
use v5.36;
use experimental qw( refaliasing declared_refs );
my \@arr = [1, 2, 3];
{
my sub inner { say "Inside inner, array is <@arr>"; }
say "Outside, array is <@arr>";
inner();
}Outside, array is <1 2 3>
Inside inner, array is <1 2 3>