Skip to content

Commit

Permalink
Fix spurious useless-use warnings in metaop+metaassign op
Browse files Browse the repository at this point in the history
Fixes RT#131251: https://rt.perl.org/Ticket/Display.html?id=131251

We check if the meta's op has is_pure annotation and cry if
it does, but the use isn't useless if our meta is a metassign.

N.B.: the check for metaassign can probably be moved up to the outer
conditional, but IIUC it'd make it too wide without is-from-core check.
  • Loading branch information
zoffixznet committed Jan 12, 2018
1 parent f41d5e8 commit cad66b7
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/Perl6/Actions.nqp
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,7 @@ sub unwanted($ast, $by) {
$op := nqp::substr($op, 0, $t) if $t > 0;
my $purity := 0;
if $node0[0].ann('is_pure') {
$purity := 1;
$purity := 1 unless $node0.name eq '&METAOP_ASSIGN';
}
else {
my $subname := $node0[0].name;
Expand Down
5 changes: 4 additions & 1 deletion t/05-messages/10-warnings.t
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use lib <t/packages/>;
use Test;
use Test::Helpers;

plan 4;
plan 5;

subtest 'Supply.interval with negative value warns' => {
plan 2;
Expand Down Expand Up @@ -67,4 +67,7 @@ is-run 「
print postcircumfix:<[ ]>(<foo bar ber>, 1)
, :out<bar>, 'no spurious warnings when invoking colonpaired routine';

is-run my $a; $a [R~]= "b"; $a [Z~]= "b"; $a [X~]= "b",
'metaops + metaassign op do not produce spurious warnings';

# vim: ft=perl6 expandtab sw=4

0 comments on commit cad66b7

Please sign in to comment.