summaryrefslogtreecommitdiff
path: root/ext
diff options
context:
space:
mode:
authorFather Chrysostomos <sprout@cpan.org>2013-09-12 14:30:41 -0700
committerFather Chrysostomos <sprout@cpan.org>2013-09-13 01:25:36 -0700
commit95a31aad58c629646a232acf2fdd010a10b1b9b5 (patch)
treea037675ea63340540ad63ea11a8f8244d7817884 /ext
parentadad97db02f9834fe787095ccf3593bf7f8d666c (diff)
downloadperl-95a31aad58c629646a232acf2fdd010a10b1b9b5.tar.gz
Fewer false positives for %hash{$scalar} warning
Instead of warning in the lexer, flag the op and then warn in op.c, when the op tree is available, so we don’t end up warning for actual lists or for sub calls. Also, only warn in scalar context, as in list context $hash{$scalar} and %hash{$scalar} do different things. In op.c we no longer have easy access to the source code, so recon- struct the hash/array access based on the op tree. This means %hash{foo} becomes %hash{"foo"}. We only reconstruct constant keys, so %hash{++$x} becomes %hash{...}. This also corrects erroneous dumps, like %hash{"} for %hash{"}"}. Instead of triggering the warning solely based on the op tree, we still keep the heuristic in toke.c, so that common workarounds for that warning (e.g., {q<key>} and {("key")}) continue to work. The heuristic in toke.c is tweaked to avoid warning for qw(). In a future commit I plan to extend this to the existing @array[0] and @hash{key} warnings, to avoid false positives.
Diffstat (limited to 'ext')
-rw-r--r--ext/B/B/Concise.pm2
1 files changed, 2 insertions, 0 deletions
diff --git a/ext/B/B/Concise.pm b/ext/B/B/Concise.pm
index 477a59a0eb..40399543ff 100644
--- a/ext/B/B/Concise.pm
+++ b/ext/B/B/Concise.pm
@@ -618,6 +618,8 @@ $priv{$_}{16} = "OURINTR" for qw(gvsv rv2sv rv2av rv2hv r2gv enteriter);
$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);
@{$priv{$_}}{32,64} = qw(BOOL BOOL?) for qw(rv2hv padhv);
$priv{substr}{16} = "REPL1ST";
$priv{$_}{16} = "TARGMY"