Skip to content

Commit

Permalink
=== should fail if not identical types
Browse files Browse the repository at this point in the history
http://irclog.perlgeek.de/perl6/2016-04-19#i_12363756

This breaks some spectests.  Since we're just after the release, I'm
going to leave them for now, hoping someone else will look at the
failures.
  • Loading branch information
lizmat committed Apr 21, 2016
1 parent a0a1e95 commit fe2be65
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 5 deletions.
7 changes: 5 additions & 2 deletions src/core/Any.pm
Original file line number Diff line number Diff line change
Expand Up @@ -425,8 +425,11 @@ Metamodel::ClassHOW.exclude_parent(Any);
# builtin ops
proto sub infix:<===>(Mu $?, Mu $?) is pure { * }
multi sub infix:<===>($?) { Bool::True }
multi sub infix:<===>($a, $b) {
nqp::p6bool(nqp::iseq_s(nqp::unbox_s($a.WHICH), nqp::unbox_s($b.WHICH)))
multi sub infix:<===>(\a, \b) {
nqp::p6bool(
nqp::eqaddr(a.WHAT,b.WHAT)
&& nqp::iseq_s(nqp::unbox_s(a.WHICH), nqp::unbox_s(b.WHICH))
)
}

proto sub infix:<before>(Mu $?, Mu $?) is pure { * }
Expand Down
5 changes: 4 additions & 1 deletion src/core/Int.pm
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,10 @@ multi sub infix:<gcd>(int $a, int $b) returns int {
}

multi sub infix:<===>(Int:D \a, Int:D \b) {
a.WHAT =:= b.WHAT && nqp::p6bool(nqp::iseq_I(nqp::decont(a), nqp::decont(b)))
nqp::p6bool(
nqp::eqaddr(a.WHAT,b.WHAT)
&& nqp::iseq_I(nqp::decont(a), nqp::decont(b))
)
}
multi sub infix:<===>(int $a, int $b) {
# hey, the optimizer is smart enough to figure that one out for us, no?
Expand Down
5 changes: 4 additions & 1 deletion src/core/Num.pm
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,10 @@ multi sub infix:«<=>»(num $a, num $b) {
}

multi sub infix:<===>(Num:D \a, Num:D \b) {
a.WHAT =:= b.WHAT && nqp::p6bool(nqp::iseq_n(nqp::unbox_n(a), nqp::unbox_n(b)))
nqp::p6bool(
nqp::eqaddr(a.WHAT,b.WHAT)
&& nqp::iseq_n(nqp::unbox_n(a), nqp::unbox_n(b))
)
}
multi sub infix:<===>(NaN, NaN) {
True;
Expand Down
5 changes: 4 additions & 1 deletion src/core/Str.pm
Original file line number Diff line number Diff line change
Expand Up @@ -1858,7 +1858,10 @@ multi sub infix:<cmp>(str $a, str $b) returns Order:D {
}

multi sub infix:<===>(Str:D \a, Str:D \b) returns Bool:D {
nqp::p6bool(nqp::iseq_s(nqp::unbox_s(a), nqp::unbox_s(b)))
nqp::p6bool(
nqp::eqaddr(a.WHAT,b.WHAT)
&& nqp::iseq_s(nqp::unbox_s(a), nqp::unbox_s(b))
)
}
multi sub infix:<===>(str $a, str $b) returns Bool:D {
nqp::p6bool(nqp::iseq_s($a, $b))
Expand Down

0 comments on commit fe2be65

Please sign in to comment.