From 4953a29997f5f0bd1a9bb3f482c8a8feb6474b91 Mon Sep 17 00:00:00 2001 From: Stefan Seifert Date: Fri, 18 Jun 2021 09:08:00 +0200 Subject: [PATCH] Fix bogus "emit without supply or react" in Supplier's TapList Avoid auto-vivification of the Scalar container for the $!tappers attribute when reading. That could lead to a Mu overwriting the list in $!tappers after we've already set $added to True in method tap, causing us to blow up when we try to call .emit on that Mu. Fixes GH #4410 --- src/core.c/Supplier.pm6 | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/core.c/Supplier.pm6 b/src/core.c/Supplier.pm6 index ab2b6424dbf..14a728c8540 100644 --- a/src/core.c/Supplier.pm6 +++ b/src/core.c/Supplier.pm6 @@ -17,6 +17,11 @@ my class Supplier { # need lock on modification). has Mu $!tappers; + # Avoid auto-vivification of the Scalar container for the $!tappers + # attribute when reading. That could lead to a Mu overwriting the list + # in $!tappers after we've already set $added to True in method tap. + submethod BUILD() { $!tappers := Mu; } + method tap(&emit, &done, &quit, &tap) { my $tle := TapListEntry.new(:&emit, :&done, :&quit); # Since we run `tap` before adding, there's a small chance of