Skip to content

Commit

Permalink
Fix for R#2514
Browse files Browse the repository at this point in the history
And similar problems with other set operators
  • Loading branch information
lizmat committed Dec 5, 2018
1 parent 194c84b commit 99d94db
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 17 deletions.
2 changes: 1 addition & 1 deletion src/core/set_addition.pm6
Expand Up @@ -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)),
Expand Down
5 changes: 4 additions & 1 deletion src/core/set_intersection.pm6
Expand Up @@ -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) {
Expand Down
8 changes: 5 additions & 3 deletions src/core/set_multiply.pm6
Expand Up @@ -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
)
}
Expand Down
32 changes: 20 additions & 12 deletions src/core/set_union.pm6
Expand Up @@ -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)
)
}

Expand Down

0 comments on commit 99d94db

Please sign in to comment.