Skip to content
Permalink
Browse files

Fix for R#2514

And similar problems with other set operators
  • Loading branch information...
lizmat committed Dec 5, 2018
1 parent 194c84b commit 99d94db4dd187d09954f0bd2698c676e292bbbd3
Showing with 30 additions and 17 deletions.
  1. +1 −1 src/core/set_addition.pm6
  2. +4 −1 src/core/set_intersection.pm6
  3. +5 −3 src/core/set_multiply.pm6
  4. +20 −12 src/core/set_union.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)),
@@ -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) {
@@ -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
)
}
@@ -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)
)
}

0 comments on commit 99d94db

Please sign in to comment.
You can’t perform that action at this time.