Commit 918ead4329 for perl

commit 918ead4329af9e9cd9c689513a24a2976c7cf806
Author: Paul Evans <leonerd@leonerd.org.uk>
Date:   Mon Nov 2 14:57:03 2026 +0000

    pp_hot.c: Fix pp_iter for indexed + refaliasing

    When the `builtin::indexed` optimisation is in effect, the block that
    increments `i` needs to recalculate the value of `refalias_this` which
    had been calculated based on the previous value of `i` to ensure that
    any refaliasing behaviour of the subsequent variables take place if
    required.

diff --git a/lib/builtin.t b/lib/builtin.t
index 1a7be037e4..e01ddb45ca 100644
--- a/lib/builtin.t
+++ b/lib/builtin.t
@@ -414,6 +414,20 @@ package FetchStoreCounter {
         'foreach + builtin::indexed LIST' );
 }

+# indexed + foreach + refalias (GH#24999)
+{
+    use feature qw( refaliasing declared_refs );
+    no warnings qw( experimental::refaliasing experimental::declared_refs );
+
+    my @output;
+    foreach my ( $idx, \@arr ) ( builtin::indexed( [qw( a b c )], [qw( d e f )] ) ) {
+        push @output, "[$idx]=<@arr>";
+    }
+
+    ok(eq_array(\@output, ['[0]=<a b c>', '[1]=<d e f>']),
+        'foreach + builtin::indexed + refalias');
+}
+
 # Vanilla trim tests
 {
     use builtin qw( trim );
diff --git a/pod/perldelta.pod b/pod/perldelta.pod
index 88e295f726..fbf499df36 100644
--- a/pod/perldelta.pod
+++ b/pod/perldelta.pod
@@ -503,6 +503,15 @@ The C<isa> operator now calls get magic on its left argument before
 checking if that value is a reference and what it is a reference to.
 [GH #24997]

+=item *
+
+No longer crashes when using multivariable C<foreach> loops with both
+refaliasing and the C<builtin::indexed> function. [GH #24999]
+
+    foreach my ( $idx, \@arr ) ( builtin::indexed @list_of_arefs ) {
+        say "Array number [$idx] contains <@arr>";
+    }
+
 =back

 =head1 Known Problems
diff --git a/pp_hot.c b/pp_hot.c
index 722ebcf1a5..bf0ab509de 100644
--- a/pp_hot.c
+++ b/pp_hot.c
@@ -5154,6 +5154,8 @@ PP(pp_iter)

                 ++i;
                 ++itersvp;
+
+                refalias_this = refalias_mask & (1<<i);
             }

             av = NULL;