From 39108997d193862a9611d910076293eea3d2cb68 Mon Sep 17 00:00:00 2001 From: Pascal Rigaux Date: Wed, 1 Oct 2003 14:54:30 +0000 Subject: also disallow map {...} %xxx --- perl_checker.src/parser_helper.ml | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'perl_checker.src') diff --git a/perl_checker.src/parser_helper.ml b/perl_checker.src/parser_helper.ml index d12a43e..5a48a10 100644 --- a/perl_checker.src/parser_helper.ml +++ b/perl_checker.src/parser_helper.ml @@ -794,12 +794,19 @@ let call_raw is_a_func (e, para) = Some(Call_op("qr//", pattern, pos) :: l) | _ -> None) - | "map" | "grep" -> + | "map" | "grep" | "grep_index" | "map_index" | "partition" + | "find" + | "any" | "every" + | "find_index" + | "each_index" -> (match para with | Anonymous_sub(None, Block [ List [ Call(Deref(I_func, Ident(None, "if_", _)), - [ List [ _ ; Deref(I_scalar, Ident(None, "_", _)) ] ]) ] ], _) :: _ -> + [ List [ _ ; Deref(I_scalar, Ident(None, "_", _)) ] ]) ] ], _) :: _ when f = "map" -> warn_rule "you can replace \"map { if_(..., $_) }\" with \"grep { ... }\"" + | [ Anonymous_sub _ ; Deref (I_hash, _) ] -> + warn_rule ("a hash is not a valid parameter to function " ^ f) + | Anonymous_sub _ :: _ -> () | _ -> warn_rule (sprintf "always use \"%s\" with a block (eg: %s { ... } @list)" f f)); None -- cgit v1.2.1