Skip to content

Commit

Permalink
Give META_REDUCE_RIGHT behavior for 1-arg case
Browse files Browse the repository at this point in the history
This aligns the behavior of `META_REDUCE_RIGHT` to that of
`META_REDUCE_LEFT` when handling 1-arg cases:

    > sub infix:<@> ($a, $b) is assoc<left> { [$a, $b] }
    > say [@] 10
    10

    > sub infix:<@> ($a, $b) is assoc<right> { [$a, $b] }
    > say [@] 10
    10

This addresses R#1705 (#1705).
  • Loading branch information
ab5tract committed May 21, 2024
1 parent cf87ccf commit f0aa962
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/core.c/metaops.rakumod
Original file line number Diff line number Diff line change
Expand Up @@ -386,7 +386,11 @@ multi sub METAOP_REDUCE_RIGHT(\op) {
),
nqp::if(
$i,
op.(nqp::atpos(nqp::getattr($v,List,'$!reified'),0)),
nqp::if(
nqp::iseq_i($i, op.count),
op.(nqp::atpos(nqp::getattr($v,List,'$!reified'),0)),
nqp::atpos(nqp::getattr($v,List,'$!reified'),0)
),
op.()
)
)
Expand Down

0 comments on commit f0aa962

Please sign in to comment.