summaryrefslogtreecommitdiffstats
path: root/perl_checker.src/parser_helper.ml
diff options
context:
space:
mode:
authorPascal Rigaux <pixel@mandriva.com>2003-04-24 19:17:03 +0000
committerPascal Rigaux <pixel@mandriva.com>2003-04-24 19:17:03 +0000
commit11ae9e70b66544b37f9c736fb58efd7bc3116461 (patch)
treeb4301c365c59dcad54eaa4b2053dcc4b3406b060 /perl_checker.src/parser_helper.ml
parentb597db85280e00cd639019c345487d1b2ac4ddaf (diff)
downloadperl_checker-11ae9e70b66544b37f9c736fb58efd7bc3116461.tar
perl_checker-11ae9e70b66544b37f9c736fb58efd7bc3116461.tar.gz
perl_checker-11ae9e70b66544b37f9c736fb58efd7bc3116461.tar.bz2
perl_checker-11ae9e70b66544b37f9c736fb58efd7bc3116461.tar.xz
perl_checker-11ae9e70b66544b37f9c736fb58efd7bc3116461.zip
- handle empty prototypes
- check number of parameters in method calls (ignoring empty overloaded methods) - allow non-empty prototypes for methods not using @_
Diffstat (limited to 'perl_checker.src/parser_helper.ml')
-rw-r--r--perl_checker.src/parser_helper.ml18
1 files changed, 11 insertions, 7 deletions
diff --git a/perl_checker.src/parser_helper.ml b/perl_checker.src/parser_helper.ml
index db6182c..fb8ba16 100644
--- a/perl_checker.src/parser_helper.ml
+++ b/perl_checker.src/parser_helper.ml
@@ -566,7 +566,11 @@ let to_Local esp =
else die_with_rawpos esp.pos "bad argument to \"local\""
let sub_declaration (name, proto) body = Sub_declaration(name, proto, Block body)
-let anonymous_sub body = Anonymous_sub (Block body.any, raw_pos2pos body.pos)
+let anonymous_sub proto body = Anonymous_sub (proto, Block body.any, raw_pos2pos body.pos)
+let call_with_same_para_special f = Call(f, [Deref(I_star, (Ident(None, "_", raw_pos2pos bpos)))])
+let remove_call_with_same_para_special = function
+ | Call(f, [Deref(I_star, (Ident(None, "_", _)))]) -> f
+ | e -> e
let cook_call_op op para pos =
(match op with
@@ -604,19 +608,19 @@ let cook_call_op op para pos =
| "=", [ Deref(I_star, (Ident _ as f1)); Deref(I_star, (Ident _ as f2)) ] ->
let s1, s2 = string_of_Ident f1, string_of_Ident f2 in
warn pos (sprintf "\"*%s = *%s\" is better written \"*%s = \\&%s\"" s1 s2 s1 s2) ;
- sub_declaration (f1, "") [ Deref(I_func, f2) ]
+ sub_declaration (f1, None) [ call_with_same_para_special(Deref(I_func, f2)) ]
| "=", [ Deref(I_star, Raw_string(sf1, pos_f1)); Deref(I_star, (Ident _ as f2)) ] ->
let s2 = string_of_Ident f2 in
warn pos (sprintf "\"*{'%s'} = *%s\" is better written \"*{'%s'} = \\&%s\"" sf1 s2 sf1 s2) ;
- sub_declaration (Ident(None, sf1, pos_f1), "") [ Deref(I_func, f2) ]
+ sub_declaration (Ident(None, sf1, pos_f1), None) [ call_with_same_para_special(Deref(I_func, f2)) ]
| "=", [ Deref(I_star, (Ident _ as f1)); Ref(I_scalar, Deref(I_func, (Ident _ as f2))) ] ->
- sub_declaration (f1, "") [ Deref(I_func, f2) ]
+ sub_declaration (f1, None) [ call_with_same_para_special(Deref(I_func, f2)) ]
| "=", [ Deref(I_star, Raw_string(sf1, pos_f1)); Ref(I_scalar, Deref(I_func, (Ident _ as f2))) ] ->
- sub_declaration (Ident(None, sf1, pos_f1), "") [ Deref(I_func, f2) ]
+ sub_declaration (Ident(None, sf1, pos_f1), None) [ call_with_same_para_special(Deref(I_func, f2)) ]
- | "=", [ Deref(I_star, (Ident _ as f1)); (Anonymous_sub _ as sub) ] ->
- sub_declaration (f1, "") [ sub ]
+ | "=", [ Deref(I_star, (Ident _ as f1)); (Anonymous_sub(proto, sub, _)) ] ->
+ sub_declaration (f1, proto) [ sub ]
| "||", e :: _ when is_always_true e -> warn_rule "<constant> || ... is the same as <constant>"; call
| "&&", e :: _ when is_always_false e -> warn_rule "<constant> && ... is the same as <constant>"; call