summaryrefslogtreecommitdiffstats
path: root/perl_checker.src
diff options
context:
space:
mode:
Diffstat (limited to 'perl_checker.src')
-rw-r--r--perl_checker.src/parser_helper.ml5
-rw-r--r--perl_checker.src/test/suggest_better.t2
2 files changed, 7 insertions, 0 deletions
diff --git a/perl_checker.src/parser_helper.ml b/perl_checker.src/parser_helper.ml
index 67b454f..39a4590 100644
--- a/perl_checker.src/parser_helper.ml
+++ b/perl_checker.src/parser_helper.ml
@@ -1287,6 +1287,11 @@ let symops pri para_context return_context op_str left op right =
| Deref(I_array, _), List [] -> true (* allow @l == () and @l != () *)
| _ -> false)
in
+ if op_str <> "==" && op_str <> "!=" && para_context = M_float then
+ (match un_parenthesize_full left.any.expr with
+ | Call_op("last_array_index", _, _) -> warn_rule "change your expression to use @xxx instead of $#xxx"
+ | _ -> ());
+
if not skip_context_check then
(mcontext_check para_context left ; mcontext_check para_context right) ;
to_Call_op_ return_context pri op_str [prio_lo pri left; prio_lo_after pri right] left right
diff --git a/perl_checker.src/test/suggest_better.t b/perl_checker.src/test/suggest_better.t
index ef3df66..9fc4f1c 100644
--- a/perl_checker.src/test/suggest_better.t
+++ b/perl_checker.src/test/suggest_better.t
@@ -60,6 +60,8 @@ $l[$#l] you can replace $#l with -1
$#l == 0 $#x == 0 is better written @x == 1
+$#l < 0 change your expression to use @xxx instead of $#xxx
+
$l[@l] = 1 "$a[@a] = ..." is better written "push @a, ..."
xxx(@_) replace xxx(@_) with &xxx