summaryrefslogtreecommitdiff
path: root/ext/B
diff options
context:
space:
mode:
authorFather Chrysostomos <sprout@cpan.org>2013-09-14 17:23:11 -0700
committerFather Chrysostomos <sprout@cpan.org>2013-09-14 18:24:21 -0700
commit429a25554a608b64c0ee46c1ffe19bab3718a3c8 (patch)
tree14715e2179b09d1708fb9b6bf4516187b225cbe5 /ext/B
parent61c85d894087ca7f0282600eb64d5af1e7b8e5d4 (diff)
downloadperl-429a25554a608b64c0ee46c1ffe19bab3718a3c8.tar.gz
Reduce false positives for @hsh{$s} and @ary[$s] warnings
This resolves tickets #28380 and #114024. Commit 95a31aad5 did something similar to this for the new %hash{...} syntax. This commit extends it to @ slices and combines the two code paths. The heuristics in toke.c can easily produce false positives. So the op is flagged as being a candidate for the warning. Then when op.c has the op tree available, it examines it to see whether the heuristic may have been a false positive. This avoids bugs with qw "foo bar baz" and sub calls triggering the warning. The source code is no longer available for the warning, so we recon- struct it from the op tree, skipping the subscript if it is anything other than a const op. This means that @hash{$foo} comes out as @hash{...} and @hash{foo} as @hash{"foo"}. It also meeans that @hash{"]"} is displayed correctly instead of as @hash{"]. Commit 95a31aad5 also modified the heuristic for %hash{...} to exempt qw altogether. But it did not exempt it if it was preceded by a tab. So this commit rectifies that. This commit also improves the false positive detection by exempting any ops returning lists that can get past toke.c’s heuristic. I went through the entire list of ops, but I may have missed some. Also, @ slices on the lhs of = are exempt, as they change the context and are hence actually useful.
Diffstat (limited to 'ext/B')
-rw-r--r--ext/B/B/Concise.pm2
1 files changed, 1 insertions, 1 deletions
diff --git a/ext/B/B/Concise.pm b/ext/B/B/Concise.pm
index 40399543ff..c644d30245 100644
--- a/ext/B/B/Concise.pm
+++ b/ext/B/B/Concise.pm
@@ -619,7 +619,7 @@ $priv{$_}{8} = "LVSUB"
for qw(rv2av rv2gv rv2hv padav padhv aelem helem aslice hslice
av2arylen keys rkeys substr pos vec);
$priv{$_}{4} = "SLICEWARN"
- for qw(rv2hv rv2av kvhslice kvaslice padav padhv);
+ for qw(rv2hv rv2av kvhslice kvaslice padav padhv hslice aslice);
@{$priv{$_}}{32,64} = qw(BOOL BOOL?) for qw(rv2hv padhv);
$priv{substr}{16} = "REPL1ST";
$priv{$_}{16} = "TARGMY"