Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable "Useless use of %s in void context" warning for chained comparisons #22969

Open
wants to merge 1 commit into
base: blead
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions op.c
Original file line number Diff line number Diff line change
Expand Up @@ -2234,6 +2234,7 @@ Perl_scalarvoid(pTHX_ OP *arg)
case OP_GETLOGIN:
case OP_PROTOTYPE:
case OP_RUNCV:
case OP_CMPCHAIN_AND:
func_ops:
if ( (PL_opargs[o->op_type] & OA_TARGLEX)
&& (o->op_private & OPpTARGET_MY)
Expand Down
6 changes: 6 additions & 0 deletions pod/perldelta.pod
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,12 @@ negation (C<!!>) is used as a convert-to-boolean operator.

=item *

L<Useless use of %s in void context|perldiag/"Useless use of %s in void context">

This warning now triggers for use of a chained comparison like C<< 0 < $x < 1 >>.

=item *

XXX Describe change here

=back
Expand Down
8 changes: 6 additions & 2 deletions t/lib/warnings/op
Original file line number Diff line number Diff line change
Expand Up @@ -422,10 +422,12 @@ $a <=> $b; # OP_NCMP
"dsatrewq";
"diatrewq";
"igatrewq";
0 <= $a; # OP_LE
use 5.015;
__SUB__ ; # OP_RUNCV
[]; # OP_ANONLIST
grep /42/, (1,2); # OP_GREP. Not warned about (yet). Grep git logs for void_unusual to see why...
0 <= $a < 10; # OP_CMPCHAIN_AND
EXPECT
Useless use of a constant ("111") in void context at - line 2.
Useless use of repeat (x) in void context at - line 3.
Expand Down Expand Up @@ -470,8 +472,10 @@ Useless use of numeric comparison (<=>) in void context at - line 55.
Useless use of a constant ("dsatrewq") in void context at - line 56.
Useless use of a constant ("diatrewq") in void context at - line 57.
Useless use of a constant ("igatrewq") in void context at - line 58.
Useless use of __SUB__ in void context at - line 60.
Useless use of anonymous array ([]) in void context at - line 61.
Useless use of numeric le (<=) in void context at - line 59.
Useless use of __SUB__ in void context at - line 61.
Useless use of anonymous array ([]) in void context at - line 62.
Useless use of comparison chaining in void context at - line 64.
########
# op.c
use warnings 'scalar' ; close STDIN ;
Expand Down
Loading