diff options
author | David Mitchell <davem@iabyn.com> | 2022-01-19 20:05:28 +0000 |
---|---|---|
committer | David Mitchell <davem@iabyn.com> | 2022-01-19 20:38:02 +0000 |
commit | 78cc98885ff2800cd3a0eda0b60a0cbb113498a9 (patch) | |
tree | 4c91ca0626d251c45150b8c426b269704ace696d /op.c | |
parent | 90a597e55c2e3ebcb8e5566ba4c84293ce821463 (diff) | |
download | perl-78cc98885ff2800cd3a0eda0b60a0cbb113498a9.tar.gz |
make a sort with zero args a compile-time err
@a = sort @empty; # unaffected
@a = sort; # now a compile-time error
the main motivation for this is to potentially be able to treat a
colon following the 'sort' keyword as part of the sort expression,
to then be able to add sort attributes at some point, e.g.
@a = sort :num, 1,2,3;
rather than the colon being seen as part of a ?: conditional.
See http://nntp.perl.org/group/perl.perl5.porters/262425.
Diffstat (limited to 'op.c')
-rw-r--r-- | op.c | 3 |
1 files changed, 3 insertions, 0 deletions
@@ -14219,6 +14219,9 @@ Perl_ck_sort(pTHX_ OP *o) simplify_sort(o); firstkid = OpSIBLING(cLISTOPo->op_first); /* get past pushmark */ + if (!firstkid) + return too_few_arguments_pv(o,OP_DESC(o), 0); + if ((stacked = o->op_flags & OPf_STACKED)) { /* may have been cleared */ OP *kid = cUNOPx(firstkid)->op_first; /* get past null */ |