summaryrefslogtreecommitdiffstats
path: root/perl_checker.src
diff options
context:
space:
mode:
authorPascal Rigaux <pixel@mandriva.com>2003-04-10 18:49:07 +0000
committerPascal Rigaux <pixel@mandriva.com>2003-04-10 18:49:07 +0000
commit9dc403e0f6777f48eccc28d033b32881df57c521 (patch)
treef97497dfd62cda626f09ba73ebfd115f6e018180 /perl_checker.src
parentf86d36d5bd458a8fd70e1a2dd0c2cea49cc162f4 (diff)
downloadperl-MDK-Common-9dc403e0f6777f48eccc28d033b32881df57c521.tar
perl-MDK-Common-9dc403e0f6777f48eccc28d033b32881df57c521.tar.gz
perl-MDK-Common-9dc403e0f6777f48eccc28d033b32881df57c521.tar.bz2
perl-MDK-Common-9dc403e0f6777f48eccc28d033b32881df57c521.tar.xz
perl-MDK-Common-9dc403e0f6777f48eccc28d033b32881df57c521.zip
warn xxx == "ia64", xxx eq 2
Diffstat (limited to 'perl_checker.src')
-rw-r--r--perl_checker.src/parser_helper.ml18
1 files changed, 18 insertions, 0 deletions
diff --git a/perl_checker.src/parser_helper.ml b/perl_checker.src/parser_helper.ml
index 570e989..0c817ad 100644
--- a/perl_checker.src/parser_helper.ml
+++ b/perl_checker.src/parser_helper.ml
@@ -561,6 +561,24 @@ let cook_call_op(op, para, pos) =
call
let call_op_((prio, (prev_ter, op)), ter, para) (sp, pos) =
+ (match op with
+ | "==" | "!=" ->
+ if List.exists (function Undef | List(_ :: _ :: _) -> true | _ -> false) para then
+ warn_rule "don't do this"
+ else if List.exists (function String _ | Raw_string _ -> true | _ -> false) para then
+ warn_rule (sprintf "you should use a string operator, not the number operator \"%s\"" op)
+ | "<=" | ">=" | ">" | "<" | "<=>" ->
+ if List.exists (function Undef | List [] | List(_ :: _ :: _) -> true | _ -> false) para then
+ (* nb: allowing @l == () *)
+ warn_rule "don't do this"
+ else if List.exists (function String _ | Raw_string _ -> true | _ -> false) para then
+ warn_rule (sprintf "you should use a string operator, not the number operator \"%s\"" op)
+ | "le" | "ge" | "eq" | "ne" | "gt" | "lt" | "cmp" ->
+ if List.exists (function Undef | List [] | List(_ :: _ :: _) -> true | _ -> false) para then
+ warn_rule "don't do this"
+ else if List.exists (function Num _ -> true | _ -> false) para then
+ warn_rule (sprintf "you should use a number operator, not the string operator \"%s\" (or replace the number with a string)" op)
+ | _ -> ());
sp_same prev_ter ter ;
(prio, cook_call_op(op, para, pos)), (sp, pos)