From f4603c474d329c04f596dae4fe33f020a1e50a23 Mon Sep 17 00:00:00 2001 From: Pascal Rigaux Date: Wed, 12 Feb 2003 11:27:26 +0000 Subject: warn when "ref" priority is badly handled by perl_checker --- perl_checker.src/parser_helper.ml | 5 ++++- perl_checker.src/parser_helper.mli | 3 ++- 2 files changed, 6 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 680b571..622f55f 100644 --- a/perl_checker.src/parser_helper.ml +++ b/perl_checker.src/parser_helper.ml @@ -265,12 +265,15 @@ let check_parenthesized_first_argexpr word ((_, e), (_, (start, _)) as ex) = if word = "time" then die_rule "please use time() instead of time"; sp_p(ex) -let check_parenthesized_first_argexpr_with_Ident ident ((_, e), _ as ex) = +let check_parenthesized_first_argexpr_with_Ident ident ((prio, e), _ as ex) = + if prio = P_tok then (); (match ident with | Ident(Some _, _, _) -> (match e with | [e] when is_parenthesized e -> () | _ -> warn_rule "use parentheses around argument (otherwise it might cause syntax errors if the package is \"require\"d and not \"use\"d") + | Ident(None, word, _) when List.mem word ["ref"] -> + if prio <> P_tok then warn_rule "use parentheses around argument" | _ -> ()); check_parenthesized_first_argexpr (string_of_Ident ident) ex diff --git a/perl_checker.src/parser_helper.mli b/perl_checker.src/parser_helper.mli index 3b776ea..7fe749d 100644 --- a/perl_checker.src/parser_helper.mli +++ b/perl_checker.src/parser_helper.mli @@ -59,7 +59,8 @@ val check_parenthesized_first_argexpr : ('a * Types.fromparser list) * (Types.spaces * (int * 'b)) -> unit val check_parenthesized_first_argexpr_with_Ident : Types.fromparser -> - ('a * Types.fromparser list) * (Types.spaces * (int * 'b)) -> unit + (Types.priority * Types.fromparser list) * (Types.spaces * (int * 'a)) -> + unit val check_hash_subscript : ('a * Types.fromparser) * ('b * (int * int)) -> unit val check_arrow_needed : -- cgit v1.2.1