Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
RT #125123: Improve error message when assigning a Str to a native in…
…t array

this works by realizing that the multi-dispatcher unbox for us into the int
candidate when possible.

The ticket acutally talks about the error message from push, but assignment has the
same problem.
  • Loading branch information
moritz committed Nov 14, 2015
1 parent cecaae2 commit f5fbcde
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions src/core/native_array.pm
Expand Up @@ -23,14 +23,21 @@ class array does Iterable is repr('VMArray') {
multi method ASSIGN-POS(array:D: Int:D $idx, int $value) {
nqp::bindpos_i(self, $idx, $value)
}
multi method ASSIGN-POS(array:D: Any $idx, int $value) {
nqp::bindpos_i(self, $idx.Int, $value)
}
multi method ASSIGN-POS(array:D: int $idx, Int:D $value) {
nqp::bindpos_i(self, $idx, $value)
}
multi method ASSIGN-POS(array:D: Int:D $idx, Mu \value) {
nqp::bindpos_i(self, $idx, value)
multi method ASSIGN-POS(array:D: Int $idx, Int:D $value) {
nqp::bindpos_i(self, $idx, $value)
}
multi method ASSIGN-POS(array:D: Any:D $idx, Mu \value) {
nqp::bindpos_i(self, $idx.Int, value)
multi method ASSIGN-POS(array:D: Any $idx, Mu \value) {
X::TypeCheck.new(
operation => 'assignment to array',
got => value,
expected => T,
).throw;
}

multi method STORE(array:D: $value) {
Expand Down

0 comments on commit f5fbcde

Please sign in to comment.