Skip to content

Commit

Permalink
Fix bogus "emit without supply or react" in Supplier's TapList
Browse files Browse the repository at this point in the history
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
  • Loading branch information
niner committed Jun 18, 2021
1 parent 4f61a10 commit 4953a29
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/core.c/Supplier.pm6
Expand Up @@ -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
Expand Down

0 comments on commit 4953a29

Please sign in to comment.