diff options
author | Pascal Rigaux <pixel@mandriva.com> | 2003-05-26 11:44:29 +0000 |
---|---|---|
committer | Pascal Rigaux <pixel@mandriva.com> | 2003-05-26 11:44:29 +0000 |
commit | 3d38c96f5f50aac80b7352b9d2129db93ecde002 (patch) | |
tree | c53b386f3a60838ca439e6078e95879ab8c02217 /perl_checker.src | |
parent | 0d99c9e73026839ce4a7dfc4617cf7df22aef64c (diff) | |
download | perl_checker-3d38c96f5f50aac80b7352b9d2129db93ecde002.tar perl_checker-3d38c96f5f50aac80b7352b9d2129db93ecde002.tar.gz perl_checker-3d38c96f5f50aac80b7352b9d2129db93ecde002.tar.bz2 perl_checker-3d38c96f5f50aac80b7352b9d2129db93ecde002.tar.xz perl_checker-3d38c96f5f50aac80b7352b9d2129db93ecde002.zip |
- warn things like: if ($a = 1) { ... }
- undef is always false
Diffstat (limited to 'perl_checker.src')
-rw-r--r-- | perl_checker.src/parser_helper.ml | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/perl_checker.src/parser_helper.ml b/perl_checker.src/parser_helper.ml index dd3428f..654999a 100644 --- a/perl_checker.src/parser_helper.ml +++ b/perl_checker.src/parser_helper.ml @@ -97,6 +97,7 @@ let is_always_false = function | Raw_string(s, _) -> s = "" | String(l, _) -> l = [] | List [] -> true + | Ident(None, "undef", _) -> true | _ -> false let not_complex e = @@ -606,6 +607,11 @@ let cook_call_op op para pos = let l = string_of_Ident l in warn_rule (sprintf "use \"push @%s, map { ... } ...\" instead of \"foreach (...) { push @%s, ... }\"\n or sometimes \"@%s = map { ... } ...\"" l l l) | _ -> ()) + | "if" -> + (match para with + | List [Call_op ("=", [ _; e ], _)] :: _ when is_always_true e || is_always_false e -> + warn_rule "are you sure you did not mean \"==\" instead of \"=\"?" + | _ -> ()) | _ -> ()); let call = Call_op(op, para, raw_pos2pos pos) in match op, para with |