diff options
author | Pascal Rigaux <pixel@mandriva.com> | 2003-05-23 13:45:12 +0000 |
---|---|---|
committer | Pascal Rigaux <pixel@mandriva.com> | 2003-05-23 13:45:12 +0000 |
commit | 23d1206401f04a5445f66a56bb7fd487ae8083e0 (patch) | |
tree | 0f806f9ce5d3dc501b4289269c0b4787c068ec44 /perl_checker.src/parser_helper.ml | |
parent | c9bfa38fe2413feb0c4495242fa8886c7f4669d3 (diff) | |
download | perl_checker-23d1206401f04a5445f66a56bb7fd487ae8083e0.tar perl_checker-23d1206401f04a5445f66a56bb7fd487ae8083e0.tar.gz perl_checker-23d1206401f04a5445f66a56bb7fd487ae8083e0.tar.bz2 perl_checker-23d1206401f04a5445f66a56bb7fd487ae8083e0.tar.xz perl_checker-23d1206401f04a5445f66a56bb7fd487ae8083e0.zip |
- suggest any instead of grep in scalar context
- suggest foreach instead of map in empty context
Diffstat (limited to 'perl_checker.src/parser_helper.ml')
-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 0e37cf5..e19dfe1 100644 --- a/perl_checker.src/parser_helper.ml +++ b/perl_checker.src/parser_helper.ml @@ -978,6 +978,9 @@ let mcontext_check_raw wanted_mcontext esp f_lower f_greater f_err = f_err()) let mcontext_check wanted_mcontext esp = + (match un_parenthesize_full esp.any.expr with + | Call(Deref(I_func, Ident(None, "grep", _)), _) -> warn_rule "in scalar context, use \"any\" instead of \"grep\"" + | _ -> ()); mcontext_check_raw wanted_mcontext esp (fun () -> ()) (fun () -> ()) (fun () -> ()) let mcontext_symops wanted_mcontext esp1 esp2 = @@ -1003,6 +1006,8 @@ let mcontext_rightops wanted_mcontext esp1 esp2 = let mcontext_unop wanted_mcontext esp = mcontext_check wanted_mcontext esp ; wanted_mcontext +let mcontext_unop_l wanted_mcontext esp = mcontext_unop wanted_mcontext { esp with any = { esp.any with expr = List esp.any.expr } } + let mcontext_check_non_none esp = if esp.mcontext = M_none then warn_rule "() context not accepted here" @@ -1014,6 +1019,7 @@ let mcontext_check_none esp = match esp.any with | [List [Num("1", _)]; Semi_colon] -> () (* allow "1;" for package return value. It would be much better to check we are at toplevel, but hell i don't want to wire this information up to here *) | [List [Call_op ("<>", [Ident (None, "STDIN", _)], _)]; Semi_colon] -> () (* allow <STDIN> to ask "press return" *) + | [List [Call(Deref(I_func, Ident(None, "map", _)), _)]; Semi_colon] -> warn_rule "if you don't use the return value, use \"foreach\" instead of \"map\"" | _ -> warn_rule "value is dropped" let mcontext_op_assign left right = |