diff --git a/src/core/set_addition.pm6 b/src/core/set_addition.pm6 index e9080477df3..2b849537b4d 100644 --- a/src/core/set_addition.pm6 +++ b/src/core/set_addition.pm6 @@ -144,7 +144,7 @@ multi sub infix:<(+)>(Any $, Failure:D $b) { $b.throw } multi sub infix:<(+)>(Failure:D $a, Any $) { $a.throw } multi sub infix:<(+)>(Any $a, Any $b) { nqp::if( - nqp::istype($a,QuantHash), + nqp::istype($a,QuantHash) && nqp::isconcrete($a), nqp::if( nqp::istype($a,Mixy) || nqp::istype($b,Mixy), infix:<(+)>($a.Mixy, $b.Mix(:view)), diff --git a/src/core/set_intersection.pm6 b/src/core/set_intersection.pm6 index a82064efbad..f4a3154e464 100644 --- a/src/core/set_intersection.pm6 +++ b/src/core/set_intersection.pm6 @@ -130,7 +130,10 @@ multi sub infix:<(&)>(Failure:D $a, Any $) { $a.throw } # Note that we cannot create a Setty:D,Any candidate because that will result # in an ambiguous dispatch, so we need to hack a check for Setty in here. multi sub infix:<(&)>(Any $a, Any $b) { - infix:<(&)>(nqp::istype($a,Setty) ?? $a !! $a.Set,$b.Set) + infix:<(&)>( + nqp::istype($a,Setty) && nqp::isconcrete($a) ?? $a !! $a.Set, + $b.Set + ) } multi sub infix:<(&)>(**@p) { diff --git a/src/core/set_multiply.pm6 b/src/core/set_multiply.pm6 index b5b5d8137f4..9ab84737991 100644 --- a/src/core/set_multiply.pm6 +++ b/src/core/set_multiply.pm6 @@ -54,9 +54,11 @@ multi sub infix:<(.)>(Failure:D $a, Any $) { $a.throw } # in here. multi sub infix:<(.)>(Any $a, Any $b) { infix:<(.)>( - nqp::istype($a,Setty) - ?? $a.Baggy - !! nqp::istype($a,Baggy) ?? $a !! $a.Bag, + nqp::isconcrete($a) + ?? nqp::istype($a,Setty) + ?? $a.Baggy + !! nqp::istype($a,Baggy) ?? $a !! $a.Bag + !! $a.Bag, $b.Bag ) } diff --git a/src/core/set_union.pm6 b/src/core/set_union.pm6 index 93d7fe2a0af..4ef8271edbd 100644 --- a/src/core/set_union.pm6 +++ b/src/core/set_union.pm6 @@ -154,25 +154,33 @@ multi sub infix:<(|)>(Failure:D $a, Any $b) { $a.throw } multi sub infix:<(|)>(Any $a, Failure:D $b) { $b.throw } multi sub infix:<(|)>(Any $a, Any $b) { nqp::if( - nqp::istype($a,Mixy), - infix:<(|)>($a, $b.Mix), + nqp::isconcrete($a), nqp::if( - nqp::istype($a,Baggy), - infix:<(|)>($a, $b.Bag), + nqp::istype($a,Mixy), + infix:<(|)>($a, $b.Mix), nqp::if( - nqp::istype($a,Setty), - infix:<(|)>($a, $b.Set), + nqp::istype($a,Baggy), + infix:<(|)>($a, $b.Bag), nqp::if( - nqp::istype($b,Mixy), - infix:<(|)>($a.Mix, $b), + nqp::istype($a,Setty), + infix:<(|)>($a, $b.Set), nqp::if( - nqp::istype($b,Baggy), - infix:<(|)>($a.Bag, $b), - infix:<(|)>($a.Set, $b.Set) + nqp::isconcrete($b), + nqp::if( + nqp::istype($b,Mixy), + infix:<(|)>($a.Mix, $b), + nqp::if( + nqp::istype($b,Baggy), + infix:<(|)>($a.Bag, $b), + infix:<(|)>($a.Set, $b.Set) + ) + ), + infix:<(|)>($a, $b.Set) ) ) ) - ) + ), + infix:<(|)>($a.Set, $b) ) }