summaryrefslogtreecommitdiffstats
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
commit9b204c4fd2e13cf7e406e29a2df78c8545b02730 (patch)
tree17e3435a23c2393b207721c60c6d060895c098e3
parent85ad03dc0777dd8450d349b30e2347da6e317f86 (diff)
downloadperl_checker-9b204c4fd2e13cf7e406e29a2df78c8545b02730.tar
perl_checker-9b204c4fd2e13cf7e406e29a2df78c8545b02730.tar.gz
perl_checker-9b204c4fd2e13cf7e406e29a2df78c8545b02730.tar.bz2
perl_checker-9b204c4fd2e13cf7e406e29a2df78c8545b02730.tar.xz
perl_checker-9b204c4fd2e13cf7e406e29a2df78c8545b02730.zip
warn xxx == "ia64", xxx eq 2
-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)