Skip to content
Permalink
Browse files

Improve error message for Associative >>op<< Iterable§

  • Loading branch information...
lizmat committed Nov 16, 2018
1 parent 481dbf9 commit 64a47d87278ca8702979bce21dbd05ba3f5ac9c7
Showing with 15 additions and 4 deletions.
  1. +15 −4 src/core/Hyper.pm6
@@ -15,6 +15,19 @@ class Hyper {
)
}

# for error messages
method name() {
my str $name = $!operator.name || 'infix:<op>';
my int $start = nqp::index($name,"«");
$start = nqp::index($name,"<") if $start == -1;
my int $end = nqp::index($name,"»");
$end = nqp::index($name,">") if $end == -1;

($!dwim-left ?? '<<' !! '>>')
~ nqp::substr($name,$start + 1,$end - $start -1)
~ ($!dwim-right ?? '>>' !! '<<')
}

proto method infix(|) {*}

# x >>op<< y
@@ -40,8 +53,7 @@ class Hyper {

# %x >>op<< ...
multi method infix(Associative:D \left, List:D \right) {
die "{left.^name} {$!operator.name} {right.^name} can never work
reliably: the order of keys in {left.^name} is indeterminate"
die "{left.^name} $.name {right.^name} can never work reliably: order of keys in {left.^name} is indeterminate"
}

# %x >>op<< y
@@ -64,8 +76,7 @@ class Hyper {

# ... >>op<< %y
multi method infix(List:D \left, Associative:D \right) {
die "{left.^name} {$!operator.name} {right.^name} can never work
reliably: the order of keys in {right.^name} is indeterminate"
die "{left.^name} $.name {right.^name} can never work reliably: order of keys in {right.^name} is indeterminate"
}

# x >>op<< %y

0 comments on commit 64a47d8

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