Skip to content

Commit

Permalink
Make error on 123 +< (1 +< 64) little more awesome
Browse files Browse the repository at this point in the history
Also for +> .  Adds error class X::NYI::BigInt, perhaps also useful for other
cases.  In response to RT #126941.
  • Loading branch information
lizmat committed Dec 17, 2015
1 parent cf72c2d commit f609147
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
8 changes: 8 additions & 0 deletions src/core/Exception.pm
Expand Up @@ -629,6 +629,14 @@ my class X::NYI::Available is X::NYI {
"Please install { self.available-str } for $.feature support. "
}
}
my class X::NYI::BigInt is Exception {
has $.op;
has $.big;
has $.side = 'right';
method message() {
"Big integer $!big not yet supported on {$!side}hand side of '$!op' operator"
}
}
my class X::Experimental does X::Comp {
has $.feature;
method message() { "Use of $.feature is experimental; please 'use experimental :$.feature'" }
Expand Down
9 changes: 7 additions & 2 deletions src/core/Int.pm
@@ -1,5 +1,6 @@
my class Rat { ... }
my class X::Numeric::DivideByZero { ... }
my class X::NYI::BigInt { ... }

my class Int { ... }
my subset UInt of Int where * >= 0;
Expand Down Expand Up @@ -351,14 +352,18 @@ multi sub infix:<+^>(int $a, int $b) {
}

multi sub infix+<»(Int:D \a, Int:D \b) returns Int:D {
nqp::bitshiftl_I(nqp::decont(a), nqp::unbox_i(b), Int)
nqp::isbig_I(nqp::decont(b))
?? fail X::NYI::BigInt.new(:op('+<'),:big(b))
!! nqp::bitshiftl_I(nqp::decont(a), nqp::unbox_i(b), Int)
}
multi sub infix+<»(int $a, int $b) {
nqp::bitshiftl_i($a, $b);
}

multi sub infix+>»(Int:D \a, Int:D \b) returns Int:D {
nqp::bitshiftr_I(nqp::decont(a), nqp::unbox_i(b), Int)
nqp::isbig_I(nqp::decont(b))
?? fail X::NYI::BigInt.new(:op('+>'),:big(b))
!! nqp::bitshiftr_I(nqp::decont(a), nqp::unbox_i(b), Int)
}
multi sub infix+>»(int $a, int $b) {
nqp::bitshiftr_i($a, $b)
Expand Down

0 comments on commit f609147

Please sign in to comment.