summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPascal Rigaux <pixel@mandriva.com>2003-04-02 11:59:00 +0000
committerPascal Rigaux <pixel@mandriva.com>2003-04-02 11:59:00 +0000
commit91730391723e88af3951ee6e6d79896ae9269796 (patch)
tree4db2891edea26b07dd403be67dadf53987d784ce
parent9f85d1a79fc1c8bd1542194d4730a3ff2e90e991 (diff)
downloadperl_checker-91730391723e88af3951ee6e6d79896ae9269796.tar
perl_checker-91730391723e88af3951ee6e6d79896ae9269796.tar.gz
perl_checker-91730391723e88af3951ee6e6d79896ae9269796.tar.bz2
perl_checker-91730391723e88af3951ee6e6d79896ae9269796.tar.xz
perl_checker-91730391723e88af3951ee6e6d79896ae9269796.zip
simplify handling of variables declared in "if (...) ..." to meet perl's way.
eg: if (my $i = foo()) { } else { $i; # accessing $i here is allowed } if (my $i = foo()) { } elsif ($i = bar()) { # don't use "my" for $i since it's already in scope }
-rw-r--r--perl_checker.src/global_checks.ml6
1 files changed, 2 insertions, 4 deletions
diff --git a/perl_checker.src/global_checks.ml b/perl_checker.src/global_checks.ml
index 2d74445..0ec9a62 100644
--- a/perl_checker.src/global_checks.ml
+++ b/perl_checker.src/global_checks.ml
@@ -243,12 +243,10 @@ let check_variables vars t =
let vars = check_variables_ vars expr in
let vars = check_variables_ vars (Block (my :: block)) in
Some vars
- | Call_op(op, cond :: Block first_bl :: other, _) when op = "if" || op = "while" || op = "unless" || op = "until" ->
+ | Call_op(op, l, _) when op = "if" || op = "while" || op = "unless" || op = "until" ->
let vars' = { vars with my_vars = [] :: vars.my_vars ; our_vars = [] :: vars.our_vars } in
- let vars' = check_variables_ vars' cond in
- let vars' = List.fold_left check_variables_ vars' first_bl in
+ let vars' = List.fold_left check_variables_ vars' l in
check_unused_local_variables vars' ;
- let vars = List.fold_left check_variables_ vars other in
Some vars
| Sub_declaration(Ident(fq, name, pos) as ident, _proto, Block l) ->