summaryrefslogtreecommitdiffstats
path: root/perl_checker.src
diff options
context:
space:
mode:
authorPascal Rigaux <pixel@mandriva.com>2003-12-15 14:35:14 +0000
committerPascal Rigaux <pixel@mandriva.com>2003-12-15 14:35:14 +0000
commit0dbfb00bcca5d560c93df23c85c5212dfc004da4 (patch)
tree6ba9c380a784724287555eae858d83f997eea4b4 /perl_checker.src
parent3e80844f82df533b22e50ff4e215ab06ae5cc78a (diff)
downloadperl_checker-0dbfb00bcca5d560c93df23c85c5212dfc004da4.tar
perl_checker-0dbfb00bcca5d560c93df23c85c5212dfc004da4.tar.gz
perl_checker-0dbfb00bcca5d560c93df23c85c5212dfc004da4.tar.bz2
perl_checker-0dbfb00bcca5d560c93df23c85c5212dfc004da4.tar.xz
perl_checker-0dbfb00bcca5d560c93df23c85c5212dfc004da4.zip
- correctly handle "shift" with no parameter at toplevel
- remove (hopefully) unused code rewriting shift -> shift(@_)
Diffstat (limited to 'perl_checker.src')
-rw-r--r--perl_checker.src/global_checks.ml3
-rw-r--r--perl_checker.src/parser_helper.ml3
2 files changed, 4 insertions, 2 deletions
diff --git a/perl_checker.src/global_checks.ml b/perl_checker.src/global_checks.ml
index 6e7b46c..0c45783 100644
--- a/perl_checker.src/global_checks.ml
+++ b/perl_checker.src/global_checks.ml
@@ -281,6 +281,9 @@ let check_variables vars t =
| Call(Deref(I_func, Ident(None, "require", _)), [Ident _]) -> Some vars
+ | Call(Deref(I_func, Ident(None, "shift", pos)) as var, []) ->
+ check vars (Call(var, [ Deref(I_array, Ident(None, (if vars.is_toplevel then "ARGV" else "_"), pos)) ]))
+
| Call(Deref(context, (Ident(_, _, pos) as var)), para) ->
check_variable (context, var) vars (Some(pos, para)) ;
let vars = List.fold_left check_variables_ vars para in
diff --git a/perl_checker.src/parser_helper.ml b/perl_checker.src/parser_helper.ml
index caaf0e7..ba30b58 100644
--- a/perl_checker.src/parser_helper.ml
+++ b/perl_checker.src/parser_helper.ml
@@ -311,7 +311,6 @@ let word_alone esp =
Call(Deref(I_func, word), [var_dollar_ pos])
| "split" -> Call(Deref(I_func, word), [ Raw_string(" ", pos) ; var_dollar_ pos ])
- | "shift" -> Call(Deref(I_func, word), [ Deref(I_array, Ident(None, "_", raw_pos2pos bpos)) ])
| "die" -> Call(Deref(I_func, word), [ Deref(I_scalar, Ident(None, "@", raw_pos2pos bpos)) ])
| "return" | "eof" | "caller"
| "redo" | "next" | "last" ->
@@ -855,7 +854,7 @@ let call_one_scalar_para { any = e ; pos = pos } para esp_start esp_end =
match para with
| [] ->
if e = "shift" then
- [ Deref(I_array, Ident(None, "_", raw_pos2pos pos)) ]
+ [] (* can't decide here *)
else
(if not (List.mem e [ "length" ]) then warn_rule (sprintf "please use \"%s $_\" instead of \"%s\"" e e) ;
[var_dollar_ (raw_pos2pos pos)])