Skip to content
Permalink
Browse files

push|append|unshift|prepend as sub die on named parameters

Fixes #2943
  • Loading branch information...
lizmat committed Jun 1, 2019
1 parent 8540c94 commit b20ccbae44f9dbfd92dcedd4302a1b86b15c3121
Showing with 20 additions and 4 deletions.
  1. +20 −4 src/core/array_operators.pm6
@@ -50,16 +50,32 @@ proto sub shift($, *%) {*}
multi sub shift(@a) { @a.shift }

proto sub push($, |) {*}
multi sub push(\a, |elems) { a.push: |elems }
multi sub push(\a, |elems) {
nqp::elems(nqp::getattr(elems,Capture,q/%!hash/))
?? die "Unexpected named argument '{elems.hash.head.key}' passed"
!! a.push: |elems
}

proto sub append($, |) {*}
multi sub append(\a, |elems) { a.append: |elems }
multi sub append(\a, |elems) {
nqp::elems(nqp::getattr(elems,Capture,q/%!hash/))
?? die "Unexpected named argument '{elems.hash.head.key}' passed"
!! a.append: |elems
}

proto sub unshift($, |) {*}
multi sub unshift(\a, |elems) { a.unshift: |elems }
multi sub unshift(\a, |elems) {
nqp::elems(nqp::getattr(elems,Capture,q/%!hash/))
?? die "Unexpected named argument '{elems.hash.head.key}' passed"
!! a.unshift: |elems
}

proto sub prepend($, |) {*}
multi sub prepend(\a, |elems) { a.prepend: |elems }
multi sub prepend(\a, |elems) {
nqp::elems(nqp::getattr(elems,Capture,q/%!hash/))
?? die "Unexpected named argument '{elems.hash.head.key}' passed"
!! a.prepend: |elems
}

proto sub splice($, |) {*}
multi sub splice(@arr, |c) { @arr.splice(|c) }

0 comments on commit b20ccba

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